【发布时间】:2011-12-30 16:59:49
【问题描述】:
我有这样的事情:
<MyView>
<Style TargetType="Border" x:Key="Module">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="Padding" Value="10" />
<Setter Property="Margin" Value="10" />
</Style>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Name="Border1" Style="{StaticResource Module}">
<!--some controls with non-fixed width-->
</Border>
<Border Grid.Row="1" Name="Border2" Style="{StaticResource Module}">
<!--some controls with non-fixed width-->
</Border>
<Border Grid.Column="1" Grid.RowSpan="2" Style="{StaticResource Module}" Name="Border3">
<!--some controls with non-fixed width-->
</Border>
</Grid>
</MyView>
Border1和Border2里面的控件可能有不同的宽度,所以它们的边框也会有不同的宽度,看起来不太好。如何强制 Border1 和 Border2 边框具有相同的宽度以便看起来更好?
由于Border1和Border2的子控件宽度可能不同,手动设置相同宽度的解决方案不计算在内。
而 Border3 的内容只是占用了所有可用空间,这很好。
【问题讨论】: