我正在尝试将RowDefinition
的高度绑定到ReferenceColumn
的宽度。
<Grid x:Name="SelectionElements">
<Grid.RowDefinitions>
<RowDefinition Height="{Binding Path=Width.Value, ElementName=ReferenceColumn}" />
<RowDefinition Height="{Binding Path=Width.Value, ElementName=ReferenceColumn}" />
<RowDefinition Height="{Binding Path=Width.Value, ElementName=ReferenceColumn}" />
<RowDefinition Height="{Binding Path=Width.Value, ElementName=ReferenceColumn}" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ReferenceColumn" Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
但它不起作用(没有错误或任何其他)。
答案 0 :(得分:1)
设置实际宽度:
<Grid.RowDefinitions>
<RowDefinition Height="{Binding Path=ActualWidth, ElementName=ReferenceColumn}" />
<RowDefinition Height="{Binding Path=ActualWidth, ElementName=ReferenceColumn}" />
<RowDefinition Height="{Binding Path=ActualWidth, ElementName=ReferenceColumn}" />
<RowDefinition Height="{Binding Path=ActualWidth, ElementName=ReferenceColumn}" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ReferenceColumn" Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
答案 1 :(得分:0)
使用ActualWidth而不是Width。