Docking left and right before top and bottom


   
             

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Simple DockPanel"
      Width="250" Height="150">
<DockPanel>
  <Button DockPanel.Dock="Left">Left</Button>
  <Button DockPanel.Dock="Right">Right</Button>
  <Button DockPanel.Dock="Top">Top</Button>
  <Button DockPanel.Dock="Bottom">Bottom</Button>
  <Button>Fill</Button>
</DockPanel>
</Window>

   
    
    
    
    
    
    
    
    
    
    
    
    
     


Dock more than two objects


   
       
<Window x:Class="LayoutPanels.SimpleDock"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SimpleDock" Height="300" Width="300"
    >
    <DockPanel LastChildFill="True">
      <Button DockPanel.Dock="Top">A Stretched Top Button</Button>
      <Button DockPanel.Dock="Top" HorizontalAlignment="Center">A Centered Top Button</Button>
      <Button DockPanel.Dock="Top" HorizontalAlignment="Left">A Left-Aligned Top Button</Button>
      <Button DockPanel.Dock="Bottom">Bottom Button</Button>
      <Button DockPanel.Dock="Left">Left Button</Button>
      <Button DockPanel.Dock="Right">Right Button</Button>
      <Button >Remaining Space</Button>
    </DockPanel>
</Window>

   
    
    
    
    
    
    
     


LayoutPanels Basic Dialog Box


   
       
<Window x:Class="LayoutPanels.BasicDialogBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="BasicDialogBox" Height="300" Width="300" MinHeight="150" MinWidth="200">
  <DockPanel LastChildFill="True">
    <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal">
      <Button Margin="10,10,2,10" Padding="3,3,3,3">OK</Button>
      <Button Margin="2,10,10,10" Padding="3,3,3,3">Cancel</Button>
    </StackPanel>
    <TextBox DockPanel.Dock="Top" Margin="10">This is a test.</TextBox>
  </DockPanel>
</Window>

   
    
    
    
    
    
    
     


DockPanel with Menu, ToolBarTray, StatusBar, StackPanel


   
       

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="DockPanelWindow" Height="300" Width="300">
    <DockPanel x:Name="dockPanel1">
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File"/>
            <MenuItem Header="_Edit"/>
            <MenuItem Header="_Help"/>
        </Menu>
        <ToolBarTray Background="White" DockPanel.Dock="Top">
            <ToolBar Band="1" BandIndex="1">
                <Button>A</Button>
                <Button>B</Button>
                <Separator/>
                <Button>C</Button>
            </ToolBar>
        </ToolBarTray>
        <StatusBar DockPanel.Dock="Bottom">
            <StatusBarItem>
                <TextBlock>Ready</TextBlock>
            </StatusBarItem>
        </StatusBar>
        <StackPanel DockPanel.Dock="Left">
            <Expander Header="Useful">
                <StackPanel>
                    <Button>A</Button>
                    <Button>B</Button>
                    <Button>C</Button>
                </StackPanel>
            </Expander>
            <Expander Header="Less useful"></Expander>
            <Expander Header="Silly"></Expander>
        </StackPanel>
        <Button Padding="10 10">
            <TextBlock TextWrapping="Wrap" TextAlignment="Center">not docked</TextBlock>
        </Button>
    </DockPanel>
</Window>

   
    
    
    
    
    
    
     


DockPanel Fill


   
      

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Dock Panel Demo"
    >
    <DockPanel>
      <Button DockPanel.Dock="Top">1</Button>
      <Button DockPanel.Dock="Left">2</Button>
      <Button DockPanel.Dock="Bottom">3</Button>
      <Button DockPanel.Dock="Right">4</Button>
      <Button >5</Button> <!-- Fill -->
    </DockPanel>
</Window>

   
    
    
    
    
    
     


Put a simple StatusBar on the bottom with DockPanel


   
      

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Fun with Panels!" Height="291" Width="529">

  <DockPanel LastChildFill ="True">
    <Menu DockPanel.Dock ="Top" HorizontalAlignment="Left" Background="White">
      <MenuItem Header="_File">
        <Separator/>
        <MenuItem Header ="_Exit" />
      </MenuItem>
    </Menu>
    <StatusBar Name="statBar" DockPanel.Dock ="Bottom" 
               VerticalAlignment="Bottom" Background="Beige" >
      <StatusBarItem>
        <TextBlock>Ready</TextBlock>
      </StatusBarItem>
    </StatusBar>

    <StackPanel Background="LightSteelBlue" Orientation ="Vertical" DockPanel.Dock ="Left">
      <Label Name="lblInstruction" FontSize="15">Information</Label>
      <Label Name="lblMake">Make</Label>
      <TextBox Name="txtMake"/>
      <Label Name="lblColor">Color</Label>
      <TextBox Name="txtColor"/>
      <Label Name="lblPetName">Name</Label>
      <TextBox Name="txtPetName"/>
      <Button Name="btnOK">OK</Button>
    </StackPanel>
  
    <TextBlock Background ="LemonChiffon" FontSize ="20">test</TextBlock>
  </DockPanel>
</Window>

   
    
    
    
    
    
     


Put a Menu and toolbar on the top with DockPanel


   
      

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Fun with Panels!" Height="291" Width="529">

  <DockPanel LastChildFill ="True">
    <Menu DockPanel.Dock ="Top" HorizontalAlignment="Left" Background="White">
      <MenuItem Header="_File">
        <Separator/>
        <MenuItem Header ="_Exit" />
      </MenuItem>
    </Menu>
    <StatusBar Name="statBar" DockPanel.Dock ="Bottom" 
               VerticalAlignment="Bottom" Background="Beige" >
      <StatusBarItem>
        <TextBlock>Ready</TextBlock>
      </StatusBarItem>
    </StatusBar>

    <StackPanel Background="LightSteelBlue" Orientation ="Vertical" DockPanel.Dock ="Left">
      <Label Name="lblInstruction" FontSize="15">Information</Label>
      <Label Name="lblMake">Make</Label>
      <TextBox Name="txtMake"/>
      <Label Name="lblColor">Color</Label>
      <TextBox Name="txtColor"/>
      <Label Name="lblPetName">Name</Label>
      <TextBox Name="txtPetName"/>
      <Button Name="btnOK">OK</Button>
    </StackPanel>
  
    <TextBlock Background ="LemonChiffon" FontSize ="20">test</TextBlock>
  </DockPanel>
</Window>