SelectionPolicy Class

A policy that makes all items in the selection available.

Namespace:  Microsoft.Windows.Design.Policies
Assembly:  Microsoft.Windows.Design.Interaction (in Microsoft.Windows.Design.Interaction.dll)

public class SelectionPolicy : ItemPolicy

The SelectionPolicy type exposes the following members.

Public methodSelectionPolicyInitializes a new instance of the SelectionPolicy class.

Protected propertyContextGets the editing context for the designer. (Inherited from ItemPolicy.)
Public propertyIsSurrogateGets a value indicating whether the policy is a surrogate policy. (Inherited from ItemPolicy.)
Public propertyPolicyItemsGets an enumeration of items that are affected by this policy. (Overrides ItemPolicy.PolicyItems.)

Public methodEqualsDetermines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Protected methodGetPolicyItemsReturns the policy items from the specified selection.
Public methodGetSurrogateItemsReturns an optional set of surrogate items for this item. (Inherited from ItemPolicy.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodIsInPolicyGets a value indicating whether the specified item is to be included in the policy.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnActivatedCalled when this policy is activated. (Overrides ItemPolicy.OnActivated().)
Protected methodOnDeactivatedCalled when this policy is deactivated. (Overrides ItemPolicy.OnDeactivated().)
Protected methodOnPolicyItemsChangedRaises the PolicyItemsChanged event. (Inherited from ItemPolicy.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

Public eventPolicyItemsChangedOccurs when the policy changes. (Inherited from ItemPolicy.)

Derive from this policy and override the IsInPolicy and GetPolicyItems methods to filter the selection as necessary.

The following code example shows how to implement a custom surrogate policy for the primary selection. 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 : PrimarySelectionPolicy 
    public override bool IsSurrogate 
            return true;

    public override IEnumerable<ModelItem> GetSurrogateItems(ModelItem item) 
        ModelItem parent = item.Parent;

        if (parent != null)
            yield return parent;

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions