Q:

C# WPF XAML: Layout issues with dynamic stretching, statusbar and horizontal datagrid expansion

I split my WinMain.xaml into 3 sections (menu, frame (for page) and a statusbar):
<Window x:Class="myCrazyApp.WinMain"
    ...
    MinHeight="600" MinWidth="1000">

    <DockPanel  Width="{Binding ActualWidth,  RelativeSource = {RelativeSource AncestorType = {x:Type Window}}}"
               Height="{Binding ActualHeight, RelativeSource = {RelativeSource AncestorType = {x:Type Window}}}">

        <Menu DockPanel.Dock="Top" Height="20">
            ...MenuItems...
        </Menu>

        <Frame DockPanel.Dock="Top" Name="WinMain_FrameContent" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Top" Source="Pages\PageOne.xaml" NavigationUIVisibility="Hidden"/>

        <StatusBar DockPanel.Dock="Bottom" Background="LightSlateGray" Height="32">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="180" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" MinWidth="60"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem Grid.Column="0">
                <TextBlock Name="WinMain_TB_Log" />
            </StatusBarItem>
            <Separator Grid.Column="1" />
            <StatusBarItem Grid.Column="2">
                <ProgressBar Name="WinMain_PB" Value="0" Width="170" Height="16" />
            </StatusBarItem>
            <Separator Grid.Column="3" />
            <StatusBarItem Grid.Column="4">
                <Label Content="Status:"/>
            </StatusBarItem>
            <Separator Grid.Column="5" />
            <StatusBarItem Grid.Column="6" Padding="4" HorizontalAlignment="Center">
                <TextBlock Name="WinMain_TB_Status" />
            </StatusBarItem>
        </StatusBar>
    </DockPanel>

Then I have my PageOne.xaml filled with a datagrid:
<Page x:Class="myCrazyApp.PageOne"
  ...>

<DockPanel Background="Beige">
    <Label DockPanel.Dock="Top">MyTitle</Label>

    <Grid DockPanel.Dock="Top">
        <DataGrid x:Name="myDataGrid" x:FieldModifier="public" IsReadOnly="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" MinWidth="500" EnableColumnVirtualization="True" EnableRowVirtualization="True" Margin="0,0,0,171" />
    </Grid>
</DockPanel>

1) The status bar in the main window is not at the bottom but instead below the middle of the window and overlapped by the pages content. Why?
2) The page adapts its size horizontally to the size of the main window (which is correct) but does not vertically adapt. Why?
3) The data grid in the page does not show a vertical scrollbar and does not end horizontally at its last column (instead: it stretches endlessly to the right with an empty column/grid). Why?
Sorry for asking 3-4 questions at once but I am bogused, here.
Thanks in advance!

A:

1)

Because you have set the DockPanel.Dock attached property to Top for both the Menu and the Frame and the last child fills the DockPanel unless you set LastChildFill to false. Besides, the DockPanel fills it parent container by default so it makes no sense to bind to the ActualWidth and ActualHeight properties of the window.
Remove DockPanel.Dock="Top" from the Frame and move it below the StatusBar. Then the Frame will fill the middle "row" of the DockPanel:
<DockPanel>

    <Menu DockPanel.Dock="Top" Height="20">
        ...
    </Menu>

    <StatusBar DockPanel.Dock="Bottom" Background="LightSlateGray" Height="32">
        ...
    </StatusBar>

    <Frame>...</Frame>

</DockPanel>

2) 

It should be fixed by doing the above and possiblly also decrease the bottom margin of the DataGrid in the Page:
Margin="0,0,0,171"

3)

Because the Frame doesn't fill the DockPanel as expected. See 1).

