Partage via


RelativeSource.AncestorType Propriété

Définition

Obtient ou définit le type d’ancêtre à rechercher.

public:
 property Type ^ AncestorType { Type ^ get(); void set(Type ^ value); };
public Type AncestorType { get; set; }
member this.AncestorType : Type with get, set
Public Property AncestorType As Type

Valeur de propriété

Type d’ancêtre. La valeur par défaut est null.

Exceptions

Exemples

L’exemple suivant retourne la seconde ItemsControl rencontrée sur le chemin vers le haut à partir de l’élément cible de la liaison.

Binding myBinding = new Binding();
// Returns the second ItemsControl encountered on the upward path
// starting at the target element of the binding
myBinding.RelativeSource = new RelativeSource(
    RelativeSourceMode.FindAncestor, typeof(ItemsControl), 2);
Dim myBinding As New Binding()
' Returns the second ItemsControl encountered on the upward path
' starting at the target element of the binding
myBinding.RelativeSource = New RelativeSource(RelativeSourceMode.FindAncestor, GetType(ItemsControl), 2)

Remarques

Si la Mode propriété n’est pas définie explicitement, la définition de la AncestorType propriété ou la AncestorLevel propriété verrouille implicitement la valeur FindAncestorde la Mode propriété sur .

Utilisation du texte XAML

Pour plus d’informations XAML, consultez RelativeSource MarkupExtension.

S’applique à

Voir aussi