uielementactivationstrategy.cs

来自「wpf和cab的结合使用源码(转载)」· CS 代码 · 共 39 行

CS
39 行
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using Microsoft.Practices.CompositeUI.SmartParts;
using Microsoft.Practices.ObjectBuilder;

namespace Microsoft.Practices.CompositeUI.Windows.Activation
{
	public class UIElementActivationStrategy : BuilderStrategy
	{
		public override object BuildUp(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)
		{
			UIElement uiElement = existing as UIElement;

			if (uiElement != null)
			{
				WorkItem workItem = context.Locator.Get<WorkItem>(new DependencyResolutionLocatorKey(typeof(WorkItem), null));
				workItem.Services.Get<IUIElementActivationService>(true).UIElementAdded(uiElement);
			}

			return base.BuildUp(context, typeToBuild, existing, idToBuild);
		}

		public override object TearDown(IBuilderContext context, object item)
		{
			UIElement uiElement = item as UIElement;

			if (uiElement != null)
			{
				WorkItem workItem = context.Locator.Get<WorkItem>(new DependencyResolutionLocatorKey(typeof(WorkItem), null));
				workItem.Services.Get<IUIElementActivationService>(true).UIElementRemoved(uiElement );
			}

			return base.TearDown(context, item);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?