title: WPF Grid & Collapsed Content
body: <p>I've Got a Window with this basic layout:</p>
  
  <pre><code>&lt;Window
      MinHeight="72" MaxHeight="400" Height="Auto"
      MinWidth="460" MaxWidth="460"&gt;
      &lt;DockPanel&gt;
          &lt;!-- Footer --&gt;
          &lt;StackPanel DockPanel.Dock="Bottom"&gt;
              ...
          &lt;/StackPanel&gt;
  
          &lt;Grid&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="40" /&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="0"/&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="0" MaxHeight="40" /&gt;
              &lt;/Grid.RowDefinitions&gt;
  
              &lt;StackPanel&gt;
                  &lt;!-- Header --&gt;
              &lt;/StackPanel&gt;
  
              &lt;TextBlock Grid.Row="1" Visibility="{My Fancy Binding To collapse this}" ... /&gt;
  
              &lt;TextBlock Grid.Row="2" Visibility="{My Fancy Binding To collapse this}" ... /&gt;
          &lt;/Grid&gt;
      &lt;/DockPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>What im trying to achieve is a window that's compact when the Two TextBlock's at the bottom are Visibility="Collapsed", and expands up to a max height set when they're not.</p>
  
  <p>This works quite alright for the <code>&lt;Grid&gt;</code> but it seems that no matter how i re-arrange my layout, i can't get the window to attempt to use the minimum space, it always sits at max-size with a lot of useless whitespace.</p>
  
  <p><strong>What is happening:</strong></p>
  
  <pre>
  +-----------------------------------+
  | Header                            |
  +-----------------------------------+
  +-----------------------------------+
  +-----------------------------------+
  |                                   |
  | Wasted Space I want to            |
  | "collapse"                        |
  |                                   |
  +-----------------------------------+
  | Footer                            |
  +-----------------------------------+
  </pre>
  
  <p><strong>What I want:</strong></p>
  
  <pre>
  +-----------------------------------+
  | Header                            |
  +-----------------------------------+
  +-----------------------------------+
  +-----------------------------------+
  +-----------------------------------+
  | Footer                            |
  +-----------------------------------+
  
  Or Effectively:
  
  +-----------------------------------+
  | Header                            |
  +-----------------------------------+
  | Footer                            |
  +-----------------------------------+
  
  </pre>