I was recently trying to help my friend with a WPF layout issue and I can’t seem to figure out how to get it working either and it seems like such a simple thing, so I thought I would tap the wealth of knowledge here 🙂 What he wants is for groupbox1 to autosize to the value of maxwidth and then to stay anchored to the left while the space to the right of the groupbox grows. So to keep this simple I am just going to post some sample code of the situation now 🙂 If anyone has some light to shed on the situation please respond. Thanks everyone!
<Window x:Class="GroupBoxTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="147" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="151*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="148" />
<ColumnDefinition Width="355*" />
</Grid.ColumnDefinitions>
<GroupBox Header="groupBox1" Margin="14,12,41,8" Name="groupBox1" MaxWidth="450" Grid.Column="1">
<Grid />
</GroupBox>
<GroupBox Header="groupBox2" Margin="12,12,13,8" Name="groupBox2">
<Grid />
</GroupBox>
</Grid>
Move MaxWidth=”450″ to the ColumnDefinition and remove it from the GroupBox.