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}"/>

posted @ 2011-04-25 09:41  xiaokang088  阅读(558)  评论(0编辑  收藏  举报