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

屬性值

Type

祖系的型別。 預設值是 null

例外狀況

範例

下列會傳回從系結目標專案開始的向上路徑上遇到的第二 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如果未明確設定屬性,將 AncestorTypeAncestorLevel 屬性隱含鎖定 Mode 屬性值為 FindAncestor

XAML 文字使用方式

如需 XAML 資訊,請參閱 RelativeSource MarkupExtension

適用於

另請參閱