RelativeSource.AncestorType Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
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
Le RelativeSource mode n’est pas le FindAncestor cas.
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.