Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Gets a value indicating whether the policy is a surrogate policy.
Namespace:  Microsoft.Windows.Design.Policies
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)
Syntax
'Declaration
Public Overridable ReadOnly Property IsSurrogate As Boolean
'Usage
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
Property Value
Type: System.Boolean
true if the policy is a surrogate policy; otherwise, false.
Remarks
Surrogate policies offer an alternative set of items that are used to locate feature providers. Surrogate policies are most often used by control containers that offer additional tasks and adorners on their children. In this scenario, the container offers a surrogate policy in which the GetSurrogateItems method returns the parent of the item provided.
Examples
The following code example shows how to create a custom surrogate policy by implementing the IsSurrogate property and the GetSurrogateItems method. For a full code listing, see How to: Create a Surrogate Policy.
' 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;
        }
    }
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.Windows.Design.Policies Namespace