如果要绑定到对象上的另一个属性:
{Binding Path=PathToProperty, RelativeSource={RelativeSource Self}}
如果您想获得祖先的属性:
{Binding Path=PathToProperty,
RelativeSource={RelativeSource AncestorType={x:Type typeOfAncestor}}}
如果希望获得模板父级上的属性(因此可以在ControlTemplate中执行双向绑定)
{Binding Path=PathToProperty, RelativeSource={RelativeSource TemplatedParent}}
或者,更短的(这只适用于OneWay绑定):
{TemplateBinding Path=PathToProperty}
<Expander Grid.Row="1">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Rectangle Height="20" Width="8" Fill="#f39800"/>
<TextBlock Margin="8,0,0,0" Text="业务信息" FontSize="14px" FontFamily="微软雅黑" VerticalAlignment="Cente