title: Getting a WPF control to stretch vertically
body: <p>I can't get my WPF layout working. I want the ListBox to stretch vertically by anchoring to the bottom of the window. It currently just sizes to the height of the controls in the <code>StackPanel</code> (the Add and Remove buttons), and resizes to accomodate items that are added. In WinForms I would just set <code>ListView.Anchor</code> to <code>Top|Left|Bottom|Right</code> but I shouldn't live in the past. I've tried a number of things like putting it in a <code>DockPanel</code>, wrapping everything in <code>Canvas</code>, etc., but nothing seems to be affected.</p>
  
  <p><img src="https://i.stack.imgur.com/CpRK9.png" alt="ViewsTestListView"></p>
  
  <p>Here is my XAML:</p>
  
  <pre><code>&lt;Window x:Class="FileDropAdmin.ViewsTestListView"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
          xmlns:shared="http://schemas.markpad.net/winfx/xaml/shared"
          Title="ViewsTestListView" Height="300" Width="416"&gt;
      &lt;Grid&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto" /&gt;
              &lt;RowDefinition Height="Auto" /&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;TextBlock TextWrapping="Wrap" VerticalAlignment="Top" Text="Things:" /&gt;
          &lt;Grid Grid.Row="1"&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="4*"/&gt;
                  &lt;ColumnDefinition Width="1*"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;   
  
              &lt;ListBox x:Name="Things" DisplayMemberPath="ThingName" SelectedItem="CurrentThing" Grid.Column="0"/&gt;
              &lt;StackPanel Margin="5 0 0 0" VerticalAlignment="Top" Grid.Column="1"&gt;
                  &lt;Button x:Name="AddThing" Content="Add" Margin="0 0 0 0" VerticalAlignment="Top"/&gt;
                  &lt;Button x:Name="RemoveThing" Content="Remove" Margin="0 5 0 0" VerticalAlignment="Top"/&gt;
              &lt;/StackPanel&gt;
          &lt;/Grid&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>