แก้ไข

แชร์ผ่าน


RelativeSource Constructors

Definition

Initializes a new instance of the RelativeSource class.

Overloads

RelativeSource()

Initializes a new instance of the RelativeSource class.

RelativeSource(RelativeSourceMode)

Initializes a new instance of the RelativeSource class with an initial mode.

RelativeSource(RelativeSourceMode, Type, Int32)

Initializes a new instance of the RelativeSource class with an initial mode and additional tree-walking qualifiers for finding the desired relative source.

RelativeSource()

Initializes a new instance of the RelativeSource class.

public:
 RelativeSource();
public RelativeSource ();
Public Sub New ()

Applies to

RelativeSource(RelativeSourceMode)

Initializes a new instance of the RelativeSource class with an initial mode.

public:
 RelativeSource(System::Windows::Data::RelativeSourceMode mode);
public RelativeSource (System.Windows.Data.RelativeSourceMode mode);
new System.Windows.Data.RelativeSource : System.Windows.Data.RelativeSourceMode -> System.Windows.Data.RelativeSource
Public Sub New (mode As RelativeSourceMode)

Parameters

mode
RelativeSourceMode

One of the RelativeSourceMode values.

Applies to

RelativeSource(RelativeSourceMode, Type, Int32)

Initializes a new instance of the RelativeSource class with an initial mode and additional tree-walking qualifiers for finding the desired relative source.

public:
 RelativeSource(System::Windows::Data::RelativeSourceMode mode, Type ^ ancestorType, int ancestorLevel);
public RelativeSource (System.Windows.Data.RelativeSourceMode mode, Type ancestorType, int ancestorLevel);
new System.Windows.Data.RelativeSource : System.Windows.Data.RelativeSourceMode * Type * int -> System.Windows.Data.RelativeSource
Public Sub New (mode As RelativeSourceMode, ancestorType As Type, ancestorLevel As Integer)

Parameters

mode
RelativeSourceMode

One of the RelativeSourceMode values. For this signature to be relevant, this should be FindAncestor.

ancestorType
Type

The Type of ancestor to look for.

ancestorLevel
Int32

The ordinal position of the desired ancestor among all ancestors of the given type.

Examples

The following returns the second ItemsControl encountered on the upward path starting at the target element of the binding.

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)

Remarks

ancestorType and ancestorLevel have no relevance if given as parameters for a mode other than FindAncestor. Do not use this signature for the other RelativeSourceMode values.

Applies to