RelativeSource 构造函数

定义

初始化 RelativeSource 类的新实例。

重载

名称 说明
RelativeSource()

初始化 RelativeSource 类的新实例。

RelativeSource(RelativeSourceMode)

使用初始模式初始化类的新实例 RelativeSource

RelativeSource(RelativeSourceMode, Type, Int32)

使用初始模式和用于查找所需相对源的其他树形限定符初始化类的新实例 RelativeSource

RelativeSource()

初始化 RelativeSource 类的新实例。

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

适用于

RelativeSource(RelativeSourceMode)

使用初始模式初始化类的新实例 RelativeSource

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)

参数

mode
RelativeSourceMode

其中一个 RelativeSourceMode 值。

适用于

RelativeSource(RelativeSourceMode, Type, Int32)

使用初始模式和用于查找所需相对源的其他树形限定符初始化类的新实例 RelativeSource

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)

参数

mode
RelativeSourceMode

其中一个 RelativeSourceMode 值。 要使此签名相关,应如此 FindAncestor

ancestorType
Type

Type要查找的祖先。

ancestorLevel
Int32

给定类型的所有上级中所需祖先的序号位置。

示例

下面返回从绑定的目标元素开始向上路径上遇到的第二 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)

注解

ancestorType如果指定为除ancestorLevel其他参数以外的mode参数,则FindAncestor不具有相关性。 不要将此签名用于其他 RelativeSourceMode 值。

适用于