Bagikan melalui


RelativeSource.AncestorType Properti

Definisi

Mendapatkan atau mengatur jenis leluhur yang akan dicari.

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

Nilai Properti

Jenis leluhur. Nilai defaultnya adalah null.

Pengecualian

Contoh

Berikut ini mengembalikan yang kedua ItemsControl ditemui pada jalur ke atas yang dimulai dari elemen target pengikatan.

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)

Keterangan

Mode Jika properti tidak diatur secara eksplisit, mengatur AncestorType atau AncestorLevel properti akan secara implisit mengunci Mode nilai properti ke FindAncestor.

Penggunaan Teks XAML

Untuk informasi XAML, lihat RelativeSource MarkupExtension.

Berlaku untuk

Lihat juga