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 方法,視需要篩選選取範圍。
範例
下列程式碼範例示範如何實作主要選取的自訂代理原則。如需完整的程式碼清單,請參閱 HOW TO:建立 Surrogate 原則。
' 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
執行緒安全
這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。
請參閱
參考
Microsoft.Windows.Design.Policies 命名空間
FeatureConnector<TFeatureProviderType>