Binding Relative 示例
Binding to self :
<TextBlock Height="23" Name="textBlock4" Text="{Binding RelativeSource=
{RelativeSource Mode=Self},Path=Name}" VerticalAlignment="Top" />
Binding to Templatepartent:
<TextBlock Height="23" HorizontalAlignment="Left" Margin="12,141,0,0"
Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=Name,Converter={...}}"/>
Or:
<TextBlock Height="23" HorizontalAlignment="Left" Margin="12,141,0,0"
Text="{TemplateBinding Path=Name}"/>
Binding to Ancestor:
<TextBlock Height="23" HorizontalAlignment="Left" Margin="12,141,0,0" Text="{Binding RelativeSource={RelativeSource
Mode=FindAncestor,AncestorType=ComboBox,AncestorLevel=2},Path=Name}" VerticalAlignment="Top" />-->
<Rectangle x:Name="recIcon" Grid.Row="0" FocusVisualStyle="{x:Null}" Fill="{Binding DefaultImage,RelativeSource={RelativeSource AncestorType={x:Type
local:IconButton}}}" />-->
Binding to PreviousData:
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=PreviousData},Path=Name}"/>