none
Menu Bar and Status Bar RRS feed

  • Question

  • I would like to have a menu bar at the top of the window and a status bar at the bottom of the window.

    <Window x:Class="App.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:y="clr-namespace:App"
        Title="WPF"
        Height="380"
        Width="700"
        Background="White"
        BorderBrush="Blue"
        ResizeMode="CanMinimize" 
      
        Name="MyWindow"
        >
       
        <DockPanel Name="MyPanel">
             <Menu  DockPanel.Dock="Top" Background="Orange" Height="20" Width="708" > Menu Bar</Menu>
             <StatusBar  DockPanel.Dock="Bottom"  Background="Orange" Height="20" Width="708" >Status Bar </StatusBar>
        </DockPanel>
    </Window>


    The Menu bar shows up at the top, but the status bar shows up in the middle of the window?!


    Thursday, April 23, 2009 10:31 PM

Answers

  • This isn't the reason it's appearing at the bottom, though. The reason is that the LastChildFill property on your DockPanel is set to true (default). Either set it to false, or provide another DockPanel child that will take up the rest of the space in the window.
    Controls for WPF, Windows Forms and Silverlight at http://www.divelements.co.uk
    • Marked as answer by OdomaeB Friday, April 24, 2009 4:08 PM
    Friday, April 24, 2009 8:53 AM
  • All you have to add the VerticalAlignment="Bottom" property to Statusbar, By default VerticalAlignment is Center.

    Please check the example as follows.

    <DockPanel Name="MyPanel">
    <Menu DockPanel.Dock="Top" Background="Orange" Height="20" Width="708" >Menu Bar</Menu>
    <StatusBar DockPanel.Dock="Bottom" Background="Orange" Height="20" Width="708" VerticalAlignment="Bottom" >Status Bar
    </StatusBar>
    </DockPanel>


    • Marked as answer by OdomaeB Friday, April 24, 2009 4:08 PM
    Friday, April 24, 2009 12:09 AM

All replies

  • All you have to add the VerticalAlignment="Bottom" property to Statusbar, By default VerticalAlignment is Center.

    Please check the example as follows.

    <DockPanel Name="MyPanel">
    <Menu DockPanel.Dock="Top" Background="Orange" Height="20" Width="708" >Menu Bar</Menu>
    <StatusBar DockPanel.Dock="Bottom" Background="Orange" Height="20" Width="708" VerticalAlignment="Bottom" >Status Bar
    </StatusBar>
    </DockPanel>


    • Marked as answer by OdomaeB Friday, April 24, 2009 4:08 PM
    Friday, April 24, 2009 12:09 AM
  • This isn't the reason it's appearing at the bottom, though. The reason is that the LastChildFill property on your DockPanel is set to true (default). Either set it to false, or provide another DockPanel child that will take up the rest of the space in the window.
    Controls for WPF, Windows Forms and Silverlight at http://www.divelements.co.uk
    • Marked as answer by OdomaeB Friday, April 24, 2009 4:08 PM
    Friday, April 24, 2009 8:53 AM
  • Thanks! That worked.
    Friday, April 24, 2009 4:08 PM