title: Nested ContentControls with template
body: <p>I have a custom <em>WindowStyle</em>, the XAML looks like this:</p>
  
  <pre><code>    &lt;Style TargetType="{x:Type Window}"
         x:Key="WindowStyle"&gt;
      /** Some setters **/
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="ContentControl"&gt;
                  &lt;AdornerDecorator&gt;
                      &lt;Grid Background="#88000000"
                            x:Name="WindowBackgroundGrid"&gt;
                          &lt;Border x:Name="WindowContentBorder"
                                  Background="{DynamicResource WindowBackground}"MaxHeight="{Binding Source={x:Static SystemParameters.FullPrimaryScreenHeight}}"
                                  MaxWidth="{Binding Source={x:Static SystemParameters.FullPrimaryScreenWidth}}"
                                  Margin="20"&gt;
                              &lt;Grid&gt;
                                  &lt;Grid.RowDefinitions&gt;
                                      &lt;RowDefinition Height="Auto" /&gt;
                                      &lt;RowDefinition Height="*" /&gt;
                                  &lt;/Grid.RowDefinitions&gt;
  
                                  &lt;!-- Header --&gt;
                                  &lt;Border BorderBrush="{DynamicResource BorderBrushColor}"
                                          Background="{DynamicResource PaneHeader_Background}"
                                          Grid.Row="0"&gt;
                                      &lt;TextBlock Text="Title"Foreground="{DynamicResource DefaultForeground}"
                                                 FontSize="16"
                                                 FontWeight="Bold"
                                                 Margin="5,5,2,5" /&gt;
                                  &lt;/Border&gt;
  
                                  &lt;!-- Content --&gt;
                                  &lt;ScrollViewer Grid.Row="1"
                                                Margin="5"&gt;
                                      &lt;ContentPresenter Content="{TemplateBinding Content}" /&gt;
                                  &lt;/ScrollViewer&gt;
                              &lt;/Grid&gt;
                          &lt;/Border&gt;
                      &lt;/Grid&gt;
                  &lt;/AdornerDecorator&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Now I want the inner <code>Grid</code> in a seperate <code>Style</code> so that I can use it elsewhere.</p>
  
  <pre><code> &lt;Style x:Key="WindowContentStyle"
         TargetType="{x:Type ContentPresenter}"&gt;
      &lt;Setter Property="ContentTemplate"&gt;
          &lt;Setter.Value&gt;
              &lt;DataTemplate&gt;
                  &lt;Grid&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="Auto" /&gt;
                          &lt;RowDefinition Height="*" /&gt;
                      &lt;/Grid.RowDefinitions&gt;
  
                      &lt;!-- Header --&gt;
                          /** Border control **/
                      &lt;!-- Content --&gt;
                      &lt;ScrollViewer Grid.Row="1" 
                                    Margin="5"&gt;
                          &lt;ContentPresenter Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" /&gt;
                      &lt;/ScrollViewer&gt;
                  &lt;/Grid&gt;
              &lt;/DataTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>And I use a <code>ContenPresenter</code> in my <em>WindowStyle</em>  to present it:</p>
  
  <pre><code>&lt;ContentPresenter&gt;
      &lt;ContentPresenter.Style&gt;
          &lt;Style TargetType="{x:Type ContentPresenter}"
                 BasedOn="{StaticResource WindowContentStyle}" /&gt;
      &lt;/ContentPresenter.Style&gt;
  &lt;/ContentPresenter&gt;
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>The edit above didn't give me any errors, but it doesn't present my <em>WindowContentStyle</em>. 
  When I set the <code>Content</code> property of the <code>Window</code> control and load the style</p>
  
  <pre><code>this.window.Content = view;
  this.window.Style = (Style)Application.Current.TryFindResource("WindowStyle");
  </code></pre>
  
  <p>the content is shown in the <code>ContentPresenter</code> in the <em>WindowStyle</em>  and not in <em>WindowContentStyle</em>. Because of this, the <code>Template</code> is not used and I don't have a header with a title.</p>
  
  <p>How can I make my outer <code>ContentPresenter</code> pass on the <code>Content</code> to my inner <code>ContentPresenter</code> (the one in <em>WindowContentStyle</em>)?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Greetings
  Loetn</p>