RelativeSource的用法
<Grid x:Name="dockPanel1" Background="Red" Margin="10"> <DockPanel x:Name="d1" Background="Orange" Margin="10"> <Grid x:Name="g2" Background="Yellow" Margin="10"> <DockPanel x:Name="dockPanel2" Background="LawnGreen" Margin="10"> <TextBox x:Name="textBox1" FontSize="24" Margin="10" Text="{Binding Path=Name, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType= {x:Type DockPanel}}}"/> <TextBox x:Name="textBox2" FontSize="24" Margin="10" Text="{Binding Path=Name, RelativeSource={RelativeSource Mode=Self}}"/> </DockPanel> </Grid> </DockPanel> </Grid>
posted on 2013-03-29 09:24 JackSlaterYu 阅读(266) 评论(0) 编辑 收藏 举报