RelativeSource.AncestorLevel Właściwość

Definicja

Pobiera lub ustawia poziom modułu ancestor do wyszukania w FindAncestor trybie. Użyj wartości 1, aby wskazać ten najbliższy element docelowy powiązania.

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

Poziom ancestora. Użyj wartości 1, aby wskazać ten najbliższy element docelowy powiązania.

Przykłady

Poniżej zwraca drugi ItemsControl napotkany na ścieżce w górę rozpoczynającej się 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 jest ustawiona jawnie, ustawienie AncestorType właściwości lub AncestorLevel niejawnie zablokuje Mode wartość właściwości na FindAncestor.

Użycie tekstu w języku XAML

Aby uzyskać informacje o języku XAML, zobacz RelativeSource MarkupExtension.

Dotyczy

Zobacz też