如果要绑定到对象上的另一个属性,请执行以下操作:
{Binding Path=PathToProperty, RelativeSource={RelativeSource Self}}
如果您想获得祖先的财产:
{Binding Path=PathToProperty,
RelativeSource={RelativeSource AncestorType={x:Type typeOfAncestor}}}
如果您想在模板化的父对象上获取属性(因此可以在ControlTemplate中进行双向绑定)
{Binding Path=PathToProperty, RelativeSource={RelativeSource TemplatedParent}}
或者更短(这只适用于单向绑定):
{TemplateBinding Path=PathToProperty}