次の方法で共有


ItemPolicy.IsSurrogate プロパティ

更新 : 2007 年 11 月

ポリシーがサロゲート ポリシーであるかどうかを示す値を取得します。

名前空間 :  Microsoft.Windows.Design.Policies
アセンブリ :  Microsoft.Windows.Design.Extensibility (Microsoft.Windows.Design.Extensibility.dll 内)

構文

'宣言
Public Overridable ReadOnly Property IsSurrogate As Boolean
'使用
Dim instance As ItemPolicy
Dim value As Boolean

value = instance.IsSurrogate
public virtual bool IsSurrogate { get; }
public:
virtual property bool IsSurrogate {
    bool get ();
}
public function get IsSurrogate () : boolean

プロパティ値

型 : System.Boolean

ポリシーがサロゲート ポリシーである場合は true。それ以外の場合は false。

解説

サロゲート ポリシーは、機能プロバイダを検索するために使用される代替アイテムのセットを提供します。多くの場合、サロゲート ポリシーは、子に追加タスクと装飾を提供するコントロール コンテナによって使用されます。このシナリオでは、コンテナがサロゲート ポリシーを提供し、その GetSurrogateItems メソッドからは、指定したアイテムの親が返されます。

IsSurrogate プロパティと GetSurrogateItems メソッドを実装して、カスタム サロゲート ポリシーを作成する方法を次のコード例に示します。完全なコードの一覧については、「方法 : サロゲート ポリシーを作成する」を参照してください。

' 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;
        }
    }
}

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

ItemPolicy クラス

ItemPolicy メンバ

Microsoft.Windows.Design.Policies 名前空間

PrimarySelectionPolicy

SelectionPolicy

FeatureProvider

FeatureConnectorAttribute

その他の技術情報

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

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