title: WPF UserControl fill mainwindow
body: <p>I am having trouble getting my UserControl to properly fill/resize with the parent window. I'm writing a WPF application using MVVM. I've searched for other answers, and I haven't been able to figure this out.</p>
  
  <p>MainWindow.xaml</p>
  
  <pre><code>&lt;Window x:Class="QiXR.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:vm="clr-namespace:QiXR.ViewModel"
      xmlns:vw="clr-namespace:QiXR.View"
      Title="MainWindow"&gt;
  &lt;Window.Resources&gt;
      &lt;DataTemplate DataType="{x:Type vm:XRTestCaseListViewModel}"&gt;
          &lt;vw:XRTestCaseListView/&gt;
      &lt;/DataTemplate&gt;
  
  &lt;/Window.Resources&gt;
  &lt;Grid&gt;
      &lt;ItemsControl ItemsSource="{Binding ViewModels}" /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>UserControl</p>
  
  <pre><code>&lt;UserControl x:Class="QiXR.View.XRTestCaseListView"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           VerticalAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"&gt;
  &lt;UserControl.Resources&gt;
      &lt;Style x:Key="DataGridCheckBoxStyle" TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}"&gt;
          &lt;Setter Property="VerticalAlignment" Value="Center"/&gt;
          &lt;Setter Property="HorizontalAlignment" Value="Center"/&gt;
      &lt;/Style&gt;
  &lt;/UserControl.Resources&gt;
  
  &lt;Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch"&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="160"/&gt;
          &lt;ColumnDefinition Width="160"/&gt;
          &lt;ColumnDefinition Width="*"/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="30"/&gt;
          &lt;RowDefinition Height="*"/&gt;
          &lt;RowDefinition Height="45"/&gt;
      &lt;/Grid.RowDefinitions&gt;
  </code></pre>
  
  <p>Here's what the display looks like when I launch it
  <a href="http://i.stack.imgur.com/4M0AQ.png" rel="nofollow">UserControl in MainWindow</a></p>
  
  <p>Is it possible to do this in the xaml of either the UserControl or MainWindow? Thanks</p>