title: How to get WPF ContentControl content to stretch?
body: <p>I'm using a <code>ContentControl</code> to render various <code>UserControl</code> derivations dynamically.  I can't for the life of me figure out how to get the content to stretch when I resize the parent <code>Window</code>.  I've found many references like <a href="https://stackoverflow.com/questions/6767613/wpf-usercontrol-is-not-filling-parent-container-when-bound-at-runtime">this</a>, but it's still not working for me.  Here is a simple example:</p>
  
  <p>This is the <code>Window</code> XAML:</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication3.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Window.Resources&gt;
          &lt;ResourceDictionary Source="Dictionary1.xaml"/&gt;
      &lt;/Window.Resources&gt;
      &lt;Grid&gt;
          &lt;ContentControl VerticalAlignment="Top" 
                          HorizontalAlignment="Left" 
                          VerticalContentAlignment="Stretch" 
                          HorizontalContentAlignment="Stretch" 
                          Content="{Binding Path=ChildView}" 
                          Margin="10"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>This uses the resource file <code>Dictionary1.XAML</code>:</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:viewModels ="clr-namespace:WpfApplication3"
                      xmlns:views ="clr-namespace:WpfApplication3"&gt;
  
      &lt;DataTemplate DataType="{x:Type viewModels:UserControlViewModel}"&gt;
          &lt;views:UserControl1/&gt;
      &lt;/DataTemplate&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>Here is the code behind for the main <code>Window</code> as well as the view model classes:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
          this.DataContext = new MainViewModel();
      }
  }    
  
  public class MainViewModel
  {
      public UserControlViewModel ChildView { get; set; }
  
      public MainViewModel()
      {
          ChildView = new UserControlViewModel();
      }
  }
  
  public class UserControlViewModel
  {
  
  }
  </code></pre>
  
  <p>and finally the user control:</p>
  
  <pre><code>&lt;UserControl x:Class="WpfApplication3.UserControl1"
               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" 
               mc:Ignorable="d" 
               Background="Blue" 
               Height="141" Width="278" 
               VerticalAlignment="Stretch" 
               HorizontalAlignment="Stretch"&gt;
      &lt;Grid&gt;
  
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Here's what it looks like at run time:</p>
  
  <p><img src="https://i.stack.imgur.com/4s0LK.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/KVa1i.png" alt="enter image description here"></p>
  
  <p>What am I missing here?  How can I get the child content to behave such that it remains anchored to the top/left of the parent and the bottom/right stretches as the parent is resized?</p>