title: WPF: How to make HeaderedContentControl.Content fit height?
body: <p>I am having a form in maximize mode, within the form contains a HeaderContentControl. 
  Within the HeaderContentControl.Content, i added a DockLayout, but the problem is that DockLayout is not fit to the form height. </p>
  
  <p><img src="https://i.stack.imgur.com/AZ3LZ.png" alt="Should be fit in the form height"></p>
  
  <p>How can I resolve this problem? Here's the xaml file:</p>
  
  <pre><code>&lt;Window x:Class="Prototype.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:Prototype"
      Title="XXX"
      x:Name="frmMain"
      Width="581" Height="340" ResizeMode="CanMinimize" 
      WindowStartupLocation="CenterScreen" WindowState="Maximized" 
      WindowStyle="None" IsHitTestVisible="True" Topmost="False"  AllowsTransparency="True" Background="Transparent" Loaded="frmMain_Loaded"&gt;
      &lt;!-- Copyright Microsoft Corporation. All Rights Reserved. --&gt;
      &lt;Window.Resources&gt;
          &lt;Style TargetType="{x:Type local:MainWindow}"&gt;
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType="{x:Type local:MainWindow}"&gt;
  
                              &lt;Border Background="#FF333333"
                  BorderBrush="#FFCCCCCC"
                  BorderThickness="1"
                  CornerRadius="5"
                  Padding='2'&gt;
                                  &lt;HeaderedContentControl&gt;
                                      &lt;HeaderedContentControl.Header&gt;
                                          &lt;Grid&gt;
                                              &lt;Grid.RowDefinitions&gt;
                                                  &lt;RowDefinition Height="19*" /&gt;  
                                              &lt;/Grid.RowDefinitions&gt;
                                              &lt;Grid.ColumnDefinitions&gt;
                                                  &lt;ColumnDefinition Width="212*" /&gt;
                                                  &lt;ColumnDefinition Width="84*" /&gt;
                                                  &lt;ColumnDefinition Width='Auto' /&gt;
                                              &lt;/Grid.ColumnDefinitions&gt;
  
                                              &lt;Rectangle Grid.ColumnSpan="3" Fill="#FF505050" /&gt;
  
                                              &lt;TextBlock FontSize="13"
                                                  FontWeight='Bold'
                                                  VerticalAlignment='Center'
                                                  Margin="6,5,3,6"
                                                  Text="XXX" Grid.ColumnSpan="2" OpacityMask="#FFCECECE" Foreground="#FFF3F3F3" Height="20" /&gt;
                                              &lt;Button x:Name='WindowCloseButton'
                                                      Grid.Column="2"
                                                      Width="17"
                                                      Height="17"
                                                      Cursor='Hand'
                                                      Margin="8,6,6,8"
                                                      VerticalAlignment='Center'
                                                      Click='WindowCloseButton_Click' FontFamily="Lucida Console"&gt;
                                                  &lt;Button.Background&gt;
                                                      &lt;ImageBrush /&gt;
                                                  &lt;/Button.Background&gt;
  
                                                  &lt;Image Source="/Prototype;component/Resource/window-close.png"&gt;&lt;/Image&gt;
                                              &lt;/Button&gt;
                                          &lt;/Grid&gt;
                                      &lt;/HeaderedContentControl.Header&gt;
  
                                      &lt;!-- New Content Area --&gt;
                                      &lt;HeaderedContentControl.Content&gt;
                                          &lt;ContentPresenter Content="{TemplateBinding Content}" /&gt;
                                      &lt;/HeaderedContentControl.Content&gt;
                                  &lt;/HeaderedContentControl&gt;
                              &lt;/Border&gt;
  
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
  
          &lt;Style TargetType="{x:Type MenuItem}"&gt;
              &lt;Setter Property="Foreground" Value="#FF7B7B7B"&gt;&lt;/Setter&gt;
  
              &lt;Style.Triggers&gt;
                  &lt;Trigger Property="IsHighlighted" Value="True"&gt;
                      &lt;Setter Property="Foreground" Value="#333333"&gt;&lt;/Setter&gt;
                  &lt;/Trigger&gt;
                  &lt;Trigger Property="IsEnabled" Value="False"&gt;
                      &lt;Setter Property="Foreground" Value="#333333"&gt;&lt;/Setter&gt;
                  &lt;/Trigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
      &lt;/Window.Resources&gt;
  
  
      &lt;Grid&gt;
  
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="23" /&gt;
              &lt;RowDefinition Height="*"/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Menu Height="23" Name="menuContext" Margin="0,0" Background="#FF7B7B7B" Foreground="White" Grid.Row="0"&gt;
              &lt;MenuItem Header="File" Background="#FF7B7B7B" Foreground="White"&gt;
                  &lt;MenuItem Header="Open" Margin="0,1"/&gt;
                  &lt;MenuItem Header="Save" Margin="0,1"/&gt;
                  &lt;MenuItem Header="Exit" Margin="0,1" UseLayoutRounding="True" /&gt;
              &lt;/MenuItem&gt;
          &lt;/Menu&gt;
          &lt;Grid Grid.Row="1" ShowGridLines="True"&gt;
              &lt;DockPanel LastChildFill="True"&gt;
  
                  &lt;Border Height="25"
  
                  Background="SkyBlue"
  
                  BorderBrush="Black"
  
                  BorderThickness="1"
  
                  DockPanel.Dock="Top"&gt;
  
                      &lt;TextBlock Foreground="Black"&gt;Dock = "Top"&lt;/TextBlock&gt;
  
                  &lt;/Border&gt;
  
                  &lt;Border Height="25"
  
                  Background="SkyBlue"
  
                  BorderBrush="Black"
  
                  BorderThickness="1"
  
                  DockPanel.Dock="Top"&gt;
  
                      &lt;TextBlock Foreground="Black"&gt;Dock = "Top"&lt;/TextBlock&gt;
  
                  &lt;/Border&gt;
  
                  &lt;Border Height="25"
  
                  Background="LemonChiffon"
  
                  BorderBrush="Black"
  
                  BorderThickness="1"
  
                  DockPanel.Dock="Bottom"&gt;
  
                      &lt;TextBlock Foreground="Black"&gt;Dock = "Bottom"&lt;/TextBlock&gt;
  
                  &lt;/Border&gt;
  
                  &lt;Border Width="200"
  
                  Background="PaleGreen"
  
                  BorderBrush="Black"
  
                  BorderThickness="1"
  
                  DockPanel.Dock="Left"&gt;
  
                      &lt;TextBlock Foreground="Black"&gt;Dock = "Left"&lt;/TextBlock&gt;
  
                  &lt;/Border&gt;
  
                  &lt;Border Background="White"
  
                  BorderBrush="Black"
  
                  BorderThickness="1"&gt;
  
                      &lt;TextBlock Foreground="Black"&gt;This content will "Fill" the remaining space&lt;/TextBlock&gt;
  
                  &lt;/Border&gt;
  
              &lt;/DockPanel&gt;
          &lt;/Grid&gt;
      &lt;/Grid&gt;
  
  &lt;/Window&gt;
  </code></pre>