Sdílet prostřednictvím


SelectionPolicy-Klasse

Aktualisiert: November 2007

Eine Richtlinie, die alle Elemente in der Auswahl verfügbar macht.

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

Syntax

'Declaration
<RequiresContextItemAttribute(GetType(Selection))> _
<RequiresContextItemAttribute(GetType(Tool))> _
Public Class SelectionPolicy _
    Inherits ItemPolicy
'Usage
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

Hinweise

Leiten Sie von dieser Richtlinie ab, und überschreiben Sie die Methoden IsInPolicy und GetPolicyItems, um die Auswahl wie gewünscht zu filtern.

Beispiele

Im folgenden Codebeispiel wird dargestellt, wie Sie eine benutzerdefinierte Ersatzrichtlinie für die primäre Auswahl implementieren. Eine vollständige Codeauflistung finden Sie unter Gewusst wie: Erstellen einer Ersatzrichtlinie.

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

Vererbungshierarchie

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

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic)-Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Siehe auch

Referenz

SelectionPolicy-Member

Microsoft.Windows.Design.Policies-Namespace

ItemPolicy

FeatureProvider

FeatureConnector<TFeatureProviderType>

Weitere Ressourcen

Featureanbieter und Featureverbindungen

WPF-Designer-Erweiterbarkeit