Reputation: 7306
I have a Window with a DockPanel, and within the DockPanel I have two user controls. The "header" user control is docking at the top of the window like I expect. However, the "footer" user control does not dock at the very bottom of the window, but instead seems to dock about 500 or so pixels below the header. There's maybe another 300 pixels (I'm just guessing by where it appears in the window) below the "footer" of just empty space.
The header control has a DesignHeight of 100, and the footer control has a DesignHeight of 20.
Why is the footer not docking at the very bottom of the Window?
MainWindow.xaml code:
<Window x:Class="RATTA.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:RATTA.ViewModel"
xmlns:vw="clr-namespace:RATTA.View"
Title="RATTA" Height="800" Width="600" Background="WhiteSmoke">
<DockPanel Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<vw:HeaderVw DataContext="MainHeaderVM" DockPanel.Dock="Top" />
<vw:FooterVw DataContext="MainFooterVM" DockPanel.Dock="Bottom" />
</DockPanel>
</Window>
Upvotes: 1
Views: 805
Reputation: 1926
The DockPanel.Dock property for the last child in the DockPanel does nothing because the DockPanel's property LastChildFill
is set to true by default. Therefore, it doesn't matter what DockPanel.Dock property you assign -- if it's the last child, it's going to fill the remainder of the DockPanel.
The reason why it appears to be about 300px from the header and the bottom of the window is because when the last child fills if the last child's height is explicitly set it will sit in the center of the remaining space.
There are a few solutions which depend on your design intentions.
Upvotes: 3