RelativeSource.AncestorLevel Właściwość

Definicja

Pobiera lub ustawia poziom przodka do wyszukania w FindAncestor trybie. Użyj wartości 1, aby wskazać element docelowy powiązania najbliższego.

public:
 property int AncestorLevel { int get(); void set(int value); };
public int AncestorLevel { get; set; }
member this.AncestorLevel : int with get, set
Public Property AncestorLevel As Integer

Wartość właściwości

Int32

Poziom przodka. Użyj wartości 1, aby wskazać element docelowy powiązania najbliższego.

Przykłady

Poniższe polecenie zwraca drugi ItemsControl napotkany na ścieżce w górę, zaczynając od elementu docelowego powiązania.

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)

Uwagi

Mode Jeśli właściwość nie zostanie jawnie ustawiona, ustawienie AncestorType właściwości lub AncestorLevel niejawnie zablokuje Mode wartość właściwości na FindAncestorwartość .

Użycie tekstu w języku XAML

Aby uzyskać informacje dotyczące języka XAML, zobacz RelativeSource MarkupExtension.

Dotyczy

Zobacz też