RelativeSourceMode 枚举


描述与绑定目标的位置相对的绑定源位置。Describes the location of the binding source relative to the position of the binding target.

public enum class RelativeSourceMode
public enum RelativeSourceMode
type RelativeSourceMode = 
Public Enum RelativeSourceMode


FindAncestor 3

引用数据绑定元素的父链中的上级。Refers to the ancestor in the parent chain of the data-bound element. 这可用于绑定到特定类型的上级或其子类。You can use this to bind to an ancestor of a specific type or its subclasses. 如果您要指定 AncestorType 和/或 AncestorLevel,可以使用此模式。This is the mode you use if you want to specify AncestorType and/or AncestorLevel.

PreviousData 0

允许在当前显示的数据项列表中绑定上一个数据项(不是包含数据项的控件)。Allows you to bind the previous data item (not that control that contains the data item) in the list of data items being displayed.

Self 2

引用正在其上设置绑定的元素,并允许你将该元素的一个属性绑定到同一元素的其他属性上。Refers to the element on which you are setting the binding and allows you to bind one property of that element to another property on the same element.

TemplatedParent 1

引用应用了模板的元素,其中此模板中存在数据绑定元素。Refers to the element to which the template (in which the data-bound element exists) is applied. 这类似于设置 TemplateBindingExtension,并仅当 Binding 在模板中时适用。This is similar to setting a TemplateBindingExtension and is only applicable if the Binding is within a template.


有关示例,请参阅 RelativeSourceSee RelativeSource for examples.


XAML 文本用法XAML Text Usage

有关 XAML 信息,请参阅 RelativeSource MarkupExtensionFor XAML information, see RelativeSource MarkupExtension.