WPF window formatting not working as expected
I have a WPF windows where I want the section at the top of the window to be just the height of all the elements it contains. The bottom of the window must be adjustable in height. If the window is made taller, then the bottom should be the section that grows, not the top.
At the bottom of the window, I want it to contain two sections. The top should be height adjustable and the bottom should only be the height needed to display all of the items it contains.
If you look at the xaml code below, you can see that I have three trellises in total. The outer grid has two row definitions, where the top row is set to Auto so that the height is high enough to contain all the elements it contains. The second row should be adjustable so that it can fill the rest of the window size.
Inside the second row of the outer grid, there is another grid that should allow the first row to be flexible in height, and the second row should be tall enough for all the elements it contains.
The problem I am having is that the whole window is not full. The bottom mesh is only partially in the outer window. Why isn't the whole window filled with the bottom grid? How can I change the definition to allow this?
<Window x:Class="WPFSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="*" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid x:Name="TopGrid" VerticalAlignment="Top" Width="Auto" Height="Auto" Grid.Row="0">
<Button Height="23" HorizontalAlignment="Left" Margin="60,0,0,4" Name="button1" VerticalAlignment="Bottom" Width="75">Button</Button>
</Grid>
<Grid x:Name="BottomGrid" Width="Auto" Height="Auto" VerticalAlignment="Bottom" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Button Grid.Row="0" Height="23" Margin="60,0,61,4" Name="button2" VerticalAlignment="Bottom">Button</Button>
<Button Grid.Row="1" Height="23" Margin="60,0,61,4" Name="button3" VerticalAlignment="Bottom">Button</Button>
</Grid>
</Grid>
a source to share