RelativeSource.AncestorLevel Свойство

Определение

Возвращает или задает уровень искомого предка в режиме FindAncestor. Используйте значение 1 для указания уровня, ближайшего к целевому элементу привязки.

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

Значение свойства

Уровень предка. Используйте значение 1 для указания уровня, ближайшего к целевому элементу привязки.

Примеры

Ниже возвращается вторая ItemsControl обнаруженная на восходящем пути, начиная с целевого элемента привязки.

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)

Комментарии

Mode Если свойство не задано явным образом, задание AncestorType свойства или AncestorLevel неявно заблокирует Mode значение FindAncestorсвойства .

Использование текста XAML

Сведения о XAML см. в разделе RelativeSource MarkupExtension.

Применяется к

См. также раздел