-1
我有這樣的事情:如何使邊框控件在單個網格控件內具有相同的寬度?
<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的內容只是吃掉了所有可用空間,這是好的。
當我將寬度設置爲*時,網格並未將Border1拉伸至全寬。而「你現在擁有的東西意味着第一列將佔用盡可能多的空間,第二列將佔用所有剩餘的空間。」正是我想要的,所以不幸的是你的解決方案不能解決我的問題。 –
對不起,剛注意到你的邊界在你的行中,而不是你的列。設置你的Border的'HorizontalAlginment =「Stretch」'它應該可以工作 – Rachel