Reputation: 3462
After setting SharedSizeGroup="B"
to every second column of the subgrids. Column became unchangeable(always have one width) and width="1*" does not work. Is it possible to make that column resizeble but with SharedSizeGroup="B"
.
<Window x:Class="WpfApplication23ColumnsGroup.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid Grid.IsSharedSizeScope="True">
<Grid Height="100">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A"></ColumnDefinition>
<ColumnDefinition Width="1*" SharedSizeGroup="B"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Content="Test"></Label>
<TextBox Grid.Column="1" MinWidth="120" MaxWidth="240"></TextBox>
<TextBox Grid.Column="2" MinWidth="120" MaxWidth="240"></TextBox>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A"></ColumnDefinition>
<ColumnDefinition SharedSizeGroup="B"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Content="TestTestTest"></Label>
<TextBox Grid.Column="1"></TextBox>
<TextBox Grid.Column="2"></TextBox>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A"></ColumnDefinition>
<ColumnDefinition SharedSizeGroup="B"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Content="TestTestTestTestTestTest"></Label>
<TextBox Grid.Column="1"></TextBox>
<TextBox Grid.Column="2"></TextBox>
</Grid>
</Grid>
</Grid>
</Window>
Upvotes: 1
Views: 2026
Reputation: 183
From here:
You can set the width of a column in a Grid (or height of a row) in three different ways: auto, explicit size, or star sizing.
When you're using the SharedSizeGroup property to set multiple columns (or rows) to the same width (or height), the method that you use for setting the column width (or row height) affects the final size as follows:
- Star sizing — not honored, treated as Auto
- Absolute sizing — takes priority over Auto, columns are set to maximum explicit width
- Auto sizing — if all columns are Auto, size is set to fit the largest content. If any columns use explicit width, the explicit width value takes precedence
Upvotes: 2