WPF 如何将网格的行绑定到另一行?
WPF How can I bind a Grid's row to another row?
我得到了两个用户控件,我希望 FourSeventh 的 Grid.Row 属性 绑定到 xaml 中的 FourEighth 的 Grid.Row 属性,但是如何?
这是我的xaml
<dims:ToothControl x:Name="FourEighth" Grid.Row="3" Grid.Column="0" />
<dims:ToothControl x:Name="FourSeventh" Grid.Row="{Binding Path=FourEighth}" Grid.Column="1" /> <--error here-->
使用 ElementName
绑定,因为 Grid.Row
是附加的 属性,你有使用括号:
<dims:ToothControl x:Name="FourSeventh"
Grid.Row="{Binding (Grid.Row), ElementName=FourEighth}"
Grid.Column="1"/>
我得到了两个用户控件,我希望 FourSeventh 的 Grid.Row 属性 绑定到 xaml 中的 FourEighth 的 Grid.Row 属性,但是如何?
这是我的xaml
<dims:ToothControl x:Name="FourEighth" Grid.Row="3" Grid.Column="0" />
<dims:ToothControl x:Name="FourSeventh" Grid.Row="{Binding Path=FourEighth}" Grid.Column="1" /> <--error here-->
使用 ElementName
绑定,因为 Grid.Row
是附加的 属性,你有使用括号:
<dims:ToothControl x:Name="FourSeventh"
Grid.Row="{Binding (Grid.Row), ElementName=FourEighth}"
Grid.Column="1"/>