title: How can I make a ListBoxItem stretch Vertically
body: <p>I would like to make a <code>ListBox</code> function like a <code>Grid</code>. Each time a new item is added it should look like a a new <code>GridRow</code> was added (with a height of star). So if there are two items they will each take up half of the available space. At some point the <code>Grid</code> row will be smaller than the items <code>MinHeight</code> at which point the <code>Grid</code> will expand and a containing ScrollViewer can kick in.</p>
  
  <p>You will see this behavior with a grid inside a <code>ScrollViewer</code>. However, I need to get this working with a <code>ListBox</code> so I can just set the <code>ItemsSource</code>, create a <code>DataTemplate</code> and move on.</p>
  
  <p>The problem with the default <code>ListBox</code> <code>ItemsPanel</code> is that it will not let my first item expand to fill all the available space. </p>
  
  <p>UPDATE:
  Here's the code to get it working:</p>
  
  <pre><code>&lt;ListBox VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Width="Auto" Height="Auto"&gt;
      &lt;ListBox.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;UniformGrid Columns="1"&gt;&lt;/UniformGrid&gt;
          &lt;/ItemsPanelTemplate&gt;
      &lt;/ListBox.ItemsPanel&gt;
  &lt;/ListBox&gt;
  </code></pre>