Bagikan melalui


RelativeSource.AncestorLevel Properti

Definisi

Mendapatkan atau mengatur tingkat leluhur yang akan dicari, dalam FindAncestor mode. Gunakan 1 untuk menunjukkan yang paling dekat dengan elemen target pengikatan.

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

Nilai Properti

Tingkat leluhur. Gunakan 1 untuk menunjukkan yang paling dekat dengan elemen target pengikatan.

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