次の方法で共有


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) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

参照

参照

SelectionPolicy メンバ

Microsoft.Windows.Design.Policies 名前空間

ItemPolicy

FeatureProvider

FeatureConnector<TFeatureProviderType>

その他の技術情報

機能プロバイダと機能コネクタ

WPF デザイナの機能拡張について