RelativeSource.AncestorType Egenskap

Definition

Hämtar eller anger vilken typ av överordnad som ska sökas efter.

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

Egenskapsvärde

Typ av överordnad. Standardvärdet är null.

Undantag

Exempel

Följande returnerar den andra ItemsControl som påträffades på den uppåtgående sökvägen med början vid bindningens målelement.

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)

Kommentarer

Om egenskapen Mode inte anges explicit låser inställningen AncestorType eller AncestorLevel egenskapen implicit egenskapsvärdet Mode till FindAncestor.

XAML-textanvändning

Information om XAML finns i RelativeSource MarkupExtension.

Gäller för

Se även