title: Multiple Content Presenters in a WPF User control
body: <p>I am creating a WPF user control, its like a window where most of the layout has been setup. But there are few sections where I want users to place their controls. To achieve this I believe I need to expose some dependency properties in my user control. </p>
  
  <p>Output should be somewhat like this </p>
  
  <p><img src="https://i.stack.imgur.com/uIATy.png" alt="enter image description here"></p>
  
  <p>Code for user control</p>
  
  <pre><code>   public class Class1 : UserControl
  {
      public ContentControl Content1
      {
          get { return (ContentControl)GetValue(Content1Property); }
          set { SetValue(Content1Property, value); }
      }
  
      // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty Content1Property =
          DependencyProperty.Register("Content1", typeof(ContentControl), typeof(Class1), null);
  
      public ContentControl Content2
      {
          get { return (ContentControl)GetValue(Content2Property); }
          set { SetValue(Content2Property, value); }
      }
  
      // Using a DependencyProperty as the backing store for Content2.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty Content2Property =
          DependencyProperty.Register("Content2", typeof(ContentControl), typeof(Class1), null);
  
  
      public ContentControl Content3
      {
          get { return (ContentControl)GetValue(Content3Property); }
          set { SetValue(Content3Property, value); }
      }
  
      // Using a DependencyProperty as the backing store for Content3.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty Content3Property =
          DependencyProperty.Register("Content3", typeof(ContentControl), typeof(Class1),null);
  
  
  }
  </code></pre>
  
  <p>And the respective xaml of the control is </p>
  
  <pre><code> &lt;Style TargetType="{x:Type userControl:Class1}"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="userControl:Class1"&gt;
                  &lt;Grid ShowGridLines="True"&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="10"&gt;&lt;/ColumnDefinition&gt;
                          &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                          &lt;ColumnDefinition Width="10"&gt;&lt;/ColumnDefinition&gt;
                          &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                          &lt;ColumnDefinition Width="10"&gt;&lt;/ColumnDefinition&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="10"&gt;&lt;/RowDefinition&gt;
                          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
                          &lt;RowDefinition Height="10"&gt;&lt;/RowDefinition&gt;
                          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
                          &lt;RowDefinition Height="10"&gt;&lt;/RowDefinition&gt;
                          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
                          &lt;RowDefinition Height="10"&gt;&lt;/RowDefinition&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;TextBlock Grid.Row="1" Grid.Column="1" Text="First Content"&gt;&lt;/TextBlock&gt;
                      &lt;ContentPresenter x:Name="firstContentPresenter" ContentSource="{TemplateBinding Content1}" Grid.Row="1" Grid.Column="3"&gt;&lt;/ContentPresenter&gt;
  
  
                      &lt;TextBlock Grid.Row="3" Grid.Column="1" Text="First Content"&gt;&lt;/TextBlock&gt;
                      &lt;ContentPresenter x:Name="secondContentPresenter"  ContentSource="{TemplateBinding Content2}"  Grid.Row="3" Grid.Column="3"&gt;&lt;/ContentPresenter&gt;
  
                      &lt;TextBlock Grid.Row="5" Grid.Column="1" Text="First Content"&gt;&lt;/TextBlock&gt;
                      &lt;ContentPresenter x:Name="thirdContentPresenter"  ContentSource="{TemplateBinding Content3}"  Grid.Row="5" Grid.Column="3"&gt;&lt;/ContentPresenter&gt;
                  &lt;/Grid&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>And I am trying to use it somewhat like this</p>
  
  <pre><code> &lt;userControl:Class1 Width="200" Height="200" Background="GreenYellow"&gt;
  
      &lt;userControl:Class1.Content1&gt;
          &lt;Label&gt;I am number 1&lt;/Label&gt;
      &lt;/userControl:Class1.Content1&gt;
      &lt;userControl:Class1.Content2&gt;
          &lt;Label&gt;I am number 2&lt;/Label&gt;
      &lt;/userControl:Class1.Content2&gt;
      &lt;userControl:Class1.Content3&gt;
          &lt;Label&gt;I am number 3&lt;/Label&gt;
      &lt;/userControl:Class1.Content3&gt;
  &lt;/userControl:Class1&gt;
  </code></pre>
  
  <p>The output of the above code is nothing. </p>
  
  <p><img src="https://i.stack.imgur.com/3GCw2.png" alt="enter image description here"></p>