RelativeSource.AncestorType Свойство

Определение

Получает или задает тип искомого предка.

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

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

Тип предка. Значение по умолчанию — null.

Исключения

Объект RelativeSource не находится в режиме FindAncestor.

Примеры

Следующий код возвращает вторую 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.

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

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