I have a WPF Window with a DockPanel that contains a Menu, a TabControl, and a Status Bar. I can get the Menu to dock to the top and the Status Bar to dock to the bottom, but I can't get the Tab control to fill the area between those two controls.
<Window x:Class="MediaCatalog.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MediaCatalog"
mc:Ignorable="d"
Title="Window1" Height="450" Width="800">
<DockPanel LastChildFill="False">
<Menu Width="Auto" VerticalAlignment="Top" HorizontalAlignment="Left"
DockPanel.Dock="Top">
</Menu>
<TabControl DockPanel.Dock="Top" Margin="0,0,0,0"
BorderThickness="1,1,1,1" Height="291">
</TabControl>
<StatusBar DockPanel.Dock="Bottom" Height="22">
<StatusBar/>
</StatusBar>
</DockPanel>
The last element will fill the
DockPanelunless you setLastChildFilltofalse:Note that you shouldn't set the
DockPanel.Dockattached property of the last element.Also, you don't want to specify a default
Heightfor theTabControlif you want it to fill the remaining space.The above sample markup will make the
TabControlfill the remaining space between the topMenuand the bottomStatusBar: