title: WPF - Scrolling Listbox in an Expander
body: <p>I have an <code>Expander</code> that I want to have a <code>ListBox</code> in.  When the I open the <code>Expander</code>, the <code>ListBox</code> just expands off the screen (rather than expanding to fill what is available and then scrolling).</p>
  
  <p>Here is my XAML:</p>
  
  <pre><code>&lt;DockPanel Margin="266.25,0,455,12" Name="dockPanel1"&gt;
      &lt;StackPanel&gt;
          &lt;Expander Header="expander1" Name="expander1" Width="150" HorizontalAlignment="Left"&gt;
              &lt;Grid&gt;
                  &lt;Label&gt;Testing&lt;/Label&gt;
                  &lt;ScrollViewer&gt;
                      &lt;ListBox Name="lstBox"  FontSize="14" SelectionChanged="lstBox_SelectionChanged" /&gt;
                  &lt;/ScrollViewer&gt;
              &lt;/Grid&gt;
          &lt;/Expander&gt;
          &lt;Expander Header="expander2" Name="expander2" Width="150" HorizontalAlignment="Left"&gt;
              &lt;Grid &gt;
  
              &lt;/Grid&gt;
          &lt;/Expander&gt;
      &lt;/StackPanel&gt;
  &lt;/DockPanel&gt;
  </code></pre>
  
  <p>When <code>Expander1</code> is opened then it just expands to the size of the <code>ListBox</code> (off the screen).  If I put a size on the grid (<code>Height="275"</code>), then it does not resize with the window.  </p>
  
  <p>I want it to stretch to the size of the window, but no more.  Is there a way to do that?</p>