title: How to get StackPanel's children to fill maximum space downward?
body: <p>I simply want flowing text on the left, and a help box on the right.</p>
  
  <p>The help box should extend all the way to the bottom.</p>
  
  <p>If you take out the outer <code>StackPanel</code> below it works great.</p>
  
  <p>But for reasons of layout (I'm inserting UserControls dynamically) I need to have the wrapping <code>StackPanel</code>.</p>
  
  <p>How do I get the <code>GroupBox</code> to extend down to the bottom of the <code>StackPanel</code>, as you can see I've tried:</p>
  
  <ul>
  <li><code>VerticalAlignment="Stretch"</code></li>
  <li><code>VerticalContentAlignment="Stretch"</code> </li>
  <li><code>Height="Auto"</code></li>
  </ul>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="TestDynamic033.Test3"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Test3" Height="300" Width="600"&gt;
      &lt;StackPanel 
          VerticalAlignment="Stretch" 
          Height="Auto"&gt;
  
          &lt;DockPanel 
              HorizontalAlignment="Stretch" 
              VerticalAlignment="Stretch" 
              Height="Auto" 
              Margin="10"&gt;
  
              &lt;GroupBox 
                  DockPanel.Dock="Right" 
                  Header="Help" 
                  Width="100" 
                  Background="Beige" 
                  VerticalAlignment="Stretch" 
                  VerticalContentAlignment="Stretch" 
                  Height="Auto"&gt;
                  &lt;TextBlock Text="This is the help that is available on the news screen." TextWrapping="Wrap" /&gt;
              &lt;/GroupBox&gt;
  
              &lt;StackPanel DockPanel.Dock="Left" Margin="10" Width="Auto" HorizontalAlignment="Stretch"&gt;
                  &lt;TextBlock Text="Here is the news that should wrap around." TextWrapping="Wrap"/&gt;
              &lt;/StackPanel&gt;
  
          &lt;/DockPanel&gt;
      &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <h2>Answer:</h2>
  
  <p>Thanks Mark, using <code>DockPanel</code> instead of <code>StackPanel</code> cleared it up. In general, I find myself using <code>DockPanel</code> more and more now for WPF layouting, here's the fixed XAML:</p>
  
  <pre><code>&lt;Window x:Class="TestDynamic033.Test3"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Test3" Height="300" Width="600" MinWidth="500" MinHeight="200"&gt;
      &lt;DockPanel 
          VerticalAlignment="Stretch" 
          Height="Auto"&gt;
  
          &lt;DockPanel 
              HorizontalAlignment="Stretch" 
              VerticalAlignment="Stretch" 
              Height="Auto" 
              MinWidth="400"
              Margin="10"&gt;
  
              &lt;GroupBox 
                  DockPanel.Dock="Right" 
                  Header="Help" 
                  Width="100" 
                  VerticalAlignment="Stretch" 
                  VerticalContentAlignment="Stretch" 
                  Height="Auto"&gt;
                  &lt;Border CornerRadius="3" Background="Beige"&gt;
                      &lt;TextBlock Text="This is the help that is available on the news screen." TextWrapping="Wrap" 
  
                  Padding="5"/&gt;
                  &lt;/Border&gt;
              &lt;/GroupBox&gt;
  
              &lt;StackPanel DockPanel.Dock="Left" Margin="10" Width="Auto" HorizontalAlignment="Stretch"&gt;
                  &lt;TextBlock Text="Here is the news that should wrap around." TextWrapping="Wrap"/&gt;
              &lt;/StackPanel&gt;
  
          &lt;/DockPanel&gt;
      &lt;/DockPanel&gt;
  &lt;/Window&gt;
  </code></pre>