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

プロパティ値

Int32

先祖レベル。 バインドのターゲット要素に一番近いレベルを示すには、1 を使用します。

次は、バインディングのターゲット要素から始まる上向きのパスで検出された 2 番目 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、プロパティ値FindAncestorが暗黙的にロックModeされます。

XAML テキストの使用法

XAML の詳細については、「 RelativeSource MarkupExtension」を参照してください。

適用対象

こちらもご覧ください