SelectionPolicy 类
更新:2007 年 11 月
一个使选定内容中的所有项都可用的策略。
命名空间: Microsoft.Windows.Design.Policies
程序集: Microsoft.Windows.Design.Extensibility(在 Microsoft.Windows.Design.Extensibility.dll 中)
语法
声明
<RequiresContextItemAttribute(GetType(Selection))> _
<RequiresContextItemAttribute(GetType(Tool))> _
Public Class SelectionPolicy _
Inherits ItemPolicy
用法
Dim instance As SelectionPolicy
[RequiresContextItemAttribute(typeof(Selection))]
[RequiresContextItemAttribute(typeof(Tool))]
public class SelectionPolicy : ItemPolicy
[RequiresContextItemAttribute(typeof(Selection))]
[RequiresContextItemAttribute(typeof(Tool))]
public ref class SelectionPolicy : public ItemPolicy
public class SelectionPolicy extends ItemPolicy
备注
可从此策略派生并重写 IsInPolicy 和 GetPolicyItems 方法,以便根据需要筛选选定内容。
示例
下面的代码示例演示如何为主选项内容实现自定义代理项策略。有关完整的代码清单,请参见如何:创建代理项策略。
' The DockPanelPolicy class implements a surrogate policy that
' provides container semantics for a selected item. By using
' this policy, the DemoDockPanel container control offers
' additional tasks and adorners on its children.
Class DockPanelPolicy
Inherits PrimarySelectionPolicy
Public Overrides ReadOnly Property IsSurrogate() As Boolean
Get
Return True
End Get
End Property
Public Overrides Function GetSurrogateItems( _
ByVal item As Microsoft.Windows.Design.Model.ModelItem) _
As System.Collections.Generic.IEnumerable( _
Of Microsoft.Windows.Design.Model.ModelItem)
Dim parent As ModelItem = item.Parent
Dim e As New System.Collections.Generic.List(Of ModelItem)
If (parent IsNot Nothing) Then
e.Add(parent)
End If
Return e
End Function
End Class
// The DockPanelPolicy class implements a surrogate policy that
// provides container semantics for a selected item. By using
// this policy, the DemoDockPanel container control offers
// additional tasks and adorners on its children.
class DockPanelPolicy : PrimarySelectionPolicy
{
public override bool IsSurrogate
{
get
{
return true;
}
}
public override IEnumerable<ModelItem> GetSurrogateItems(ModelItem item)
{
ModelItem parent = item.Parent;
if (parent != null)
{
yield return parent;
}
}
}
继承层次结构
System.Object
Microsoft.Windows.Design.Policies.ItemPolicy
Microsoft.Windows.Design.Policies.SelectionPolicy
Microsoft.Windows.Design.Policies.PrimarySelectionPolicy
Microsoft.Windows.Design.Policies.SecondarySelectionPolicy
Microsoft.Windows.Design.Policies.SelectionParentPolicy
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
另请参见
参考
Microsoft.Windows.Design.Policies 命名空间
FeatureConnector<TFeatureProviderType>