Compartilhar via


Método PrimarySelectionPolicy.GetPolicyItems

Retorna o item de diretiva que representa a seleção principal.

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

Sintaxe

'Declaração
Protected Overrides Function GetPolicyItems ( _
    selection As Selection _
) As IEnumerable(Of ModelItem)
protected override IEnumerable<ModelItem> GetPolicyItems(
    Selection selection
)
protected:
virtual IEnumerable<ModelItem^>^ GetPolicyItems(
    Selection^ selection
) override
abstract GetPolicyItems : 
        selection:Selection -> IEnumerable<ModelItem> 
override GetPolicyItems : 
        selection:Selection -> IEnumerable<ModelItem> 
protected override function GetPolicyItems(
    selection : Selection
) : IEnumerable<ModelItem>

Parâmetros

Valor de retorno

Tipo: System.Collections.Generic.IEnumerable<ModelItem>
Tanto um único elemento que é a seleção principal ou uma enumeração vazia.

Exemplos

O exemplo de código a seguir mostra como criar uma diretiva personalizada de substitutos, Implementando o IsSurrogate propriedade e o GetSurrogateItems método. Para obter uma listagem de código completo, consulte Como: criar uma diretiva substituto.

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

Segurança do .NET Framework

Consulte também

Referência

PrimarySelectionPolicy Classe

Namespace Microsoft.Windows.Design.Policies

ItemPolicy

SelectionPolicy

FeatureProvider

FeatureConnectorAttribute

Outros recursos

Recurso provedores e conectores de recursos

Noções básicas sobre extensibilidade Designer WPF