一、RelativeSource属性
我们进行Bingding时,如果明确知道数据源的Name,就能用Source或者ElementName进行绑定,但是有时候我们需要绑定的数据源可能没有明确的Name,此时我们就需要利 用Bingding的RelativeSource进行绑定,这种办法的意思是指当前元素和绑定源的位置关系。
RelativeSource的三种控件
(1)控件关联自身的属性——Self
<Grid>
<StackPanel>
<TextBox Height="30" Width="60" Name="Box1" Text="{Binding RelativeSource={RelativeSource Mode=self},Path=Name }"/>
</StackPanel>
</Grid>
(2)控件关联其父级容器的属性——AncestorType
<Grid Name=