RelativeSource.AncestorType Vlastnost

Definice

Získá nebo nastaví typ nadřazeného objektu, který se má hledat.

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

Hodnota vlastnosti

Typ nadřazeného typu. Výchozí hodnota je null.

Výjimky

Příklady

Následující příkaz vrátí sekundu ItemsControl , ke které došlo na cestě nahoru počínaje cílovým prvkem vazby.

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)

Poznámky

Mode Pokud vlastnost není explicitně nastavená, nastavením AncestorType vlastnosti nebo AncestorLevel vlastnost implicitně uzamknete Mode hodnotu vlastnosti na FindAncestorhodnotu .

Použití textu XAML

Informace o XAML najdete v tématu RelativeSource MarkupExtension.

Platí pro

Viz také