Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF <StatusBar> is not positioned at the bottom of the window

Tags:

wpf

We have a WPF executable that creates a and then dynamically loads several assemblies. Each assembly represents a screen (.xaml) that is displayed in one of the tabs. The Problem is that the is right under the and not at the bottom of the window. How do I force the to always be at the bottom of the window? Thx!

UserControl    
    DockPanel
        CheckBox 
        StatusBar
    DockPanel
UserControl
like image 651
Bill Brown Avatar asked Feb 22 '10 14:02

Bill Brown


2 Answers

In addition to ArsenMkrt's answer about including the DockPanel.Dock="Bottom" attribute, don't forget that the LAST element in a DockPanel will fill the area unless you explicitly tell it otherwise using a height command (regardless of the DockPanel.Dock attribute provided).

my suggestion is to do thus:

<UserControl>
   <DockPanel>
     <StatusBar DockPanel.Dock="Bottom" />
     <CheckBox />
   </DockPanel>
</Usercontrol>
like image 59
Stephen Wrighton Avatar answered Oct 20 '22 01:10

Stephen Wrighton


I had the same problem just now. Thanks to Stephen Wrighton's tip that the last element added to a DockPanel fills the area left over, I figured out how to set up my Window. It was a bit weird since I added the Grid last but it was positioned in the middle.

<Window>
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File">
            </MenuItem>
        </Menu>

        <StatusBar DockPanel.Dock="Bottom">
            <StatusBarItem Content="Filler" />
        </StatusBar>

        <Grid x:Name="rootGrid">

        </Grid>
    </DockPanel>
</Window>
like image 30
Paul-Sebastian Manole Avatar answered Oct 20 '22 00:10

Paul-Sebastian Manole