title: Datagrid extends off window
body: <p>Hey everyone. I have a problem with a datagrid in my window. I want it to extend only to its needed size if it doesn't fill the entire window or show a scroll bar if it does take up the entire screen. Here's my xaml</p>
  
  <pre><code> &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="*"/&gt;
          &lt;RowDefinition Height="auto"/&gt;
          &lt;RowDefinition Height="auto"/&gt;
      &lt;/Grid.RowDefinitions&gt;
  
      &lt;DataGrid Grid.Row="0" Name="dg"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn Header="Col1"/&gt;
              &lt;DataGridTextColumn Header="Col1"/&gt;
          &lt;/DataGrid.Columns&gt;            
      &lt;/DataGrid&gt;
  
      &lt;GroupBox Grid.Row="2" Margin="5"&gt;
          &lt;Button&gt;Click&lt;/Button&gt;
      &lt;/GroupBox&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>If I set the row height for the datagrid to * it extends the datagrid's gray background down the entire row. But if I set the height to auto, then it won't show a scrollbar when there are too many items for the window.</p>
  
  <p>Any ideas?</p>