Layout navigation window

2.6k views Asked by At

I would like to build a WPF window application using the following layout structure. Consider title and button on left hand frame/window like "Master Pages" in ASP.Net. On the right hand frame it should be a WPF navigation window.

When I include Navigation Window as an UI element at the last stack panel, it throws me and error. How should I design the entire layout according to the image screenshot below? Thanks

<Window x:Class="MainWindow"
     xmlns:local="clr-namespace:ClientSocket"        
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title=" Desktop" Height="841" Width="1271" WindowStartupLocation="CenterScreen" WindowState="Maximized">
    <DockPanel>
        <StackPanel DockPanel.Dock ="Top"  Orientation="Horizontal" Background="Red">
            <TextBlock  Background="red"  FontSize ="36" Width="482" >
           Main Title
            </TextBlock>          
        </StackPanel>
        <StackPanel Background="LightGray" DockPanel.Dock ="Left" Width="145">
            <Button Content="Button1" Name="btnAndroid" Width="119" Margin="3" BorderBrush="{StaticResource {x:Static SystemColors.InfoBrushKey}}" />
            <Button Content="Button2" Name="btnDownloads" Width="119" Margin="3" BorderBrush="{StaticResource {x:Static SystemColors.InfoBrushKey}}" />
            <Button Content="AddNewDownloads" Height="37" Name="Button1" Width="133" />
        </StackPanel>
        <StackPanel>
        <NavigationWindow Height="auto" Width="auto" Name="nwMain" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="Blue" BorderThickness="1"  />
        </StackPanel>
    </DockPanel>
</Window>

enter image description here

1

There are 1 answers

7
brunnerh On BEST ANSWER

You cannot add a window as the child of anything, there is a nestable navigation control which you can use here instead, it is called Frame.

Layout-wise i would recommend a Grid with two rows, contains another Grid (in Grid.Row="1") with two columns.

DockPanels are sad controls that probably should not be used, unless someone points a gun at you and tells you to.