frameworkelementactivationstrategy.cs
来自「wpf和cab的结合使用源码(转载)」· CS 代码 · 共 42 行
CS
42 行
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
{
/// <summary>
/// Implements a <see cref="BuilderStrategy"/> for <see cref="FrameworkElement"/>s.
/// </summary>
public class FrameworkElementActivationStrategy : BuilderStrategy
{
public override object BuildUp(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)
{
FrameworkElement frameworkElement = existing as FrameworkElement;
if (frameworkElement != null)
{
WorkItem workItem = context.Locator.Get<WorkItem>(new DependencyResolutionLocatorKey(typeof(WorkItem), null));
workItem.Services.Get<IFrameworkElementActivationService>(true).FrameworkElementAdded(frameworkElement);
}
return base.BuildUp(context, typeToBuild, existing, idToBuild);
}
public override object TearDown(IBuilderContext context, object item)
{
FrameworkElement frameworkElement = item as FrameworkElement;
if (frameworkElement != null)
{
WorkItem workItem = context.Locator.Get<WorkItem>(new DependencyResolutionLocatorKey(typeof(WorkItem), null));
workItem.Services.Get<IFrameworkElementActivationService>(true).FrameworkElementRemoved(frameworkElement);
}
return base.TearDown(context, item);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?