title: What is the difference between the HeaderTemplate and ContainerStyle on the WPF DataGrid's GroupStyle?
body: <p>It would appear that the <code>ContainerStyle</code> is used in preference to the <code>HeaderTemplate</code> when both are specified, as below;</p>
  
  <pre><code>&lt;controls:DataGrid.GroupStyle&gt;
    &lt;GroupStyle&gt;
      &lt;GroupStyle.HeaderTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;StackPanel&gt;
            &lt;TextBlock Text="{Binding Path=Name}" Background="Yellow" /&gt;
          &lt;/StackPanel&gt;
        &lt;/DataTemplate&gt;
      &lt;/GroupStyle.HeaderTemplate&gt;
      &lt;GroupStyle.ContainerStyle&gt;
        &lt;Style TargetType="{x:Type GroupItem}"&gt;
          &lt;Setter Property="Template"&gt;
            &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type GroupItem}"&gt;
                &lt;Expander IsExpanded="true" Background="Violet"&gt;
                  &lt;Expander.Header&gt;
                    &lt;DockPanel TextBlock.FontWeight="Bold"&gt;
                      &lt;TextBlock Text="{Binding Path=Name}" /&gt;
                      &lt;TextBlock Text="{Binding Path=ItemCount}"/&gt;
                    &lt;/DockPanel&gt;
                  &lt;/Expander.Header&gt;
                  &lt;ItemsPresenter /&gt;
                &lt;/Expander&gt;
              &lt;/ControlTemplate&gt;
            &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
        &lt;/Style&gt;
      &lt;/GroupStyle.ContainerStyle&gt;
    &lt;/GroupStyle&gt;
  &lt;/controls:DataGrid.GroupStyle&gt;
  </code></pre>
  
  <p>Is the only difference that the <code>HeaderTemplate</code> does not have access to the <code>ItemsPresenter</code>, or is the difference something to do with hierarchical data structures?</p>
  
  <p>Thanks!</p>
  
  <p>Edited to link to <a href="http://wpftutorial.net/DataGrid.html#grouping" rel="nofollow">http://wpftutorial.net/DataGrid.html#grouping</a>. I didn't actually take the example directly from there, but it's a great site so they can have a link anyway.</p>