title: WPF Treeview content below ItemsPresenter
body: <p><strong>Background</strong></p>
  
  <p>I've searched fot a day now, without a good result. What I basically try to achieve is the following treeview:</p>
  
  <pre><code>&lt;Grid&gt;
      &lt;TreeView&gt;
          &lt;TreeViewItem&gt;
              &lt;TreeViewItem.Header&gt;
                  &lt;StackPanel&gt;
                      &lt;TextBlock Text="Header Content 1"/&gt;
                      &lt;TextBlock Text="Header Content 2"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/TreeViewItem.Header&gt;
              &lt;StackPanel &gt;
                  &lt;TextBlock Margin="-19,0,0,0" Text="Expandable Content 1"/&gt;
                  &lt;TextBlock Margin="-19,0,0,0" Text="Expandable Content 2"/&gt;
              &lt;/StackPanel&gt;
          &lt;/TreeViewItem&gt;
          &lt;TreeViewItem&gt;
              &lt;TreeViewItem.Header&gt;
                  &lt;StackPanel&gt;
                      &lt;TextBlock Text="Content Footer"/&gt;
                      &lt;TextBlock Text="Content Footer"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/TreeViewItem.Header&gt;
          &lt;/TreeViewItem&gt;
      &lt;/TreeView&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>The Itemspresenter of the treeview should present its content between two content panels (Header &amp; Footer), except that in the code above requires two treeview items and I would like to have it as 1 (selectable) treeview item.. </p>
  
  <p>If edited the default Controltemplate of the treeview in an attempt to add a textblock on a third row in a Grid, but for some reason it copies this textblock twice when the treeview item is expanded:</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;SolidColorBrush x:Key="GlyphBrush" Color="#444" /&gt;
      &lt;Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton"&gt;
          &lt;Setter Property="Focusable" Value="False"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="ToggleButton"&gt;
                      &lt;Grid Width="15"
                            Height="13"
                            Background="Transparent"&gt;
                      &lt;Path x:Name="ExpandPath"
                              HorizontalAlignment="Left" 
                              VerticalAlignment="Center" 
                              Margin="1,1,1,1"
                              Fill="{StaticResource GlyphBrush}"
                              Data="M 4 0 L 8 4 L 4 8 Z"/&gt;
                      &lt;/Grid&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="IsChecked" Value="True"&gt;
                              &lt;Setter Property="Data" TargetName="ExpandPath" Value="M 0 4 L 8 4 L 4 8 Z"/&gt;
                          &lt;/Trigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
      &lt;Style x:Key="TreeViewItemFocusVisual"&gt;
          &lt;Setter Property="Control.Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate&gt;
                      &lt;Border&gt;
                          &lt;Rectangle  Margin="0,0,0,0"
                                      StrokeThickness="5"
                                      Stroke="Black"
                                      StrokeDashArray="1 2"
                                      Opacity="0"/&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
      &lt;Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}"&gt;
          &lt;Setter Property="Background" Value="Transparent"/&gt;
          &lt;Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/&gt;
          &lt;Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/&gt;
          &lt;Setter Property="Padding" Value="1,0,0,0"/&gt;
          &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/&gt;
          &lt;Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type TreeViewItem}"&gt;
                      &lt;Grid&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition MinWidth="19" Width="Auto"/&gt;
                              &lt;ColumnDefinition Width="Auto"/&gt;
                              &lt;ColumnDefinition Width="*"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height="Auto"/&gt;
                              &lt;RowDefinition Height="Auto"/&gt;
                              &lt;RowDefinition/&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;ToggleButton x:Name="Expander"
                            Style="{StaticResource ExpandCollapseToggleStyle}"
                            IsChecked="{Binding Path=IsExpanded,
                            RelativeSource={RelativeSource TemplatedParent}}"
                            ClickMode="Press"/&gt;
                          &lt;Border   Name="Bd"
                                    Grid.Column="1"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Padding="{TemplateBinding Padding}"&gt;
                              &lt;ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/&gt;
                          &lt;/Border&gt;
                          &lt;ItemsPresenter x:Name="ItemsHost"
                                            Grid.Row="1"
                                            Grid.Column="1"
                                            Grid.ColumnSpan="2"/&gt;
                          &lt;TextBlock Grid.Row="2" Grid.Column="1" Text="Footer Text"&gt;&lt;/TextBlock&gt;
                      &lt;/Grid&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="IsExpanded" Value="false"&gt;
                              &lt;Setter TargetName="ItemsHost"
                                      Property="Visibility"
                                      Value="Collapsed"/&gt;
                          &lt;/Trigger&gt;
                          &lt;Trigger Property="HasItems" Value="false"&gt;
                              &lt;Setter TargetName="Expander"
                                      Property="Visibility"
                                      Value="Hidden"/&gt;
                          &lt;/Trigger&gt;
                          &lt;MultiTrigger&gt;
                              &lt;MultiTrigger.Conditions&gt;
                                  &lt;Condition Property="HasHeader" Value="false"/&gt;
                                  &lt;Condition Property="Width" Value="Auto"/&gt;
                              &lt;/MultiTrigger.Conditions&gt;
                              &lt;Setter TargetName="PART_Header" Property="MinWidth" Value="75"/&gt;
                          &lt;/MultiTrigger&gt;
                          &lt;MultiTrigger&gt;
                              &lt;MultiTrigger.Conditions&gt;
                                  &lt;Condition Property="HasHeader" Value="false"/&gt;
                                  &lt;Condition Property="Height" Value="Auto"/&gt;
                              &lt;/MultiTrigger.Conditions&gt;
                              &lt;Setter TargetName="PART_Header" Property="MinHeight" Value="19"/&gt;
                          &lt;/MultiTrigger&gt;
                          &lt;Trigger Property="IsSelected" Value="true"&gt;
                              &lt;Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/&gt;
                              &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/&gt;                            &lt;/Trigger&gt;
                          &lt;MultiTrigger&gt;
                              &lt;MultiTrigger.Conditions&gt;
                                  &lt;Condition Property="IsSelected" Value="true"/&gt;
                                  &lt;Condition Property="IsSelectionActive" Value="false"/&gt;
                              &lt;/MultiTrigger.Conditions&gt;
                              &lt;Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/&gt;
                              &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/&gt;
                          &lt;/MultiTrigger&gt;
                          &lt;Trigger Property="IsEnabled" Value="false"&gt;
                              &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/&gt;
                          &lt;/Trigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/Window.Resources&gt;
  &lt;Grid&gt;
      &lt;TreeView&gt;
          &lt;TreeViewItem&gt;
              &lt;TreeViewItem.Header&gt;
                  &lt;StackPanel&gt;
                      &lt;TextBlock Text="Treeview Item 1"/&gt;
                      &lt;TextBlock Text="Header Content"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/TreeViewItem.Header&gt;
              &lt;StackPanel &gt;
                  &lt;TextBlock Margin="-19,0,0,0" Text="Expandable Content 1"/&gt;
                  &lt;TextBlock Margin="-19,0,0,0" Text="Expandable Content 2"/&gt;
              &lt;/StackPanel&gt;
          &lt;/TreeViewItem&gt;
          &lt;TreeViewItem&gt;
              &lt;TreeViewItem.Header&gt;
                  &lt;StackPanel&gt;
                      &lt;TextBlock Text="Treeview Item 2"/&gt;
                      &lt;TextBlock Text="Header Content"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/TreeViewItem.Header&gt;
              &lt;StackPanel &gt;
                  &lt;TextBlock Margin="-19,0,0,0" Text="Expandable Content 1"/&gt;
                  &lt;TextBlock Margin="-19,0,0,0" Text="Expandable Content 2"/&gt;
              &lt;/StackPanel&gt;
          &lt;/TreeViewItem&gt;
      &lt;/TreeView&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>In the example above the Footer Content is shown twice because it is added to the bottom of the Itemspresenter. </p>
  
  <p><strong>Question</strong></p>
  
  <p>Does anyone know how to solve this? Or perhaps knows a different approach to achieve the same result?</p>