title: WPF Add Button To Bottom Of Treeview
body: <p>this is probably going to seem like a daft question but please bear with me as I am very new to WPF, UI is sadly not my main area of skills and so I'm struggling to get my head around the concepts of WPF.</p>
  
  <p>I have a user control which contains a dock panel which then contains a tree view, the tree view is being bound using a Hierarchical Data Template which is working great, all the items and sub controls are being bound and I'm pleased with the rough layout result.  However I wanted to add a button under the last bound tree view item.</p>
  
  <p>Basically this is what I am trying to acheive : <img src="https://i.stack.imgur.com/B5x4i.jpg" alt="enter image description here"></p>
  
  <p>At the moment I have a Grid inside the dock panel which has two rows, one for the tree view and one for the button but obviously the button is not part of the tree view, I want it to be within the scrolling area of the tree view so it appears as part of it and only appearing after the final item.</p>
  
  <p>Here is my current XAML:</p>
  
  <pre><code>&lt;DockPanel&gt;
      &lt;Grid Width="Auto" Height="Auto"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="*"/&gt;
              &lt;RowDefinition Height="23"/&gt;
          &lt;/Grid.RowDefinitions&gt;
      &lt;TreeView ItemsSource="{Binding Path=Steps}" FontFamily="Calibri" FontSize="14" DataContext="{Binding}" Grid.Row="0"&gt;
          &lt;TreeView.ItemContainerStyle&gt;
              &lt;Style TargetType="{x:Type TreeViewItem}"&gt;
                  &lt;Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/&gt;
                  &lt;Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/&gt;
                  &lt;Setter Property="FontWeight" Value="Normal"/&gt;
                  &lt;Setter Property="Margin" Value="20,20,0,0"/&gt;
                  &lt;Style.Triggers&gt;
                      &lt;Trigger Property="IsSelected" Value="True"&gt;
                          &lt;Setter Property="FontWeight" Value="Bold"/&gt;
                      &lt;/Trigger&gt;
                  &lt;/Style.Triggers&gt;
              &lt;/Style&gt;
          &lt;/TreeView.ItemContainerStyle&gt;
          &lt;TreeView.Resources&gt;
              &lt;HierarchicalDataTemplate DataType="{x:Type local:StepViewModel}" ItemsSource="{Binding Segments}"&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;TextBlock Text="{Binding Name}" /&gt;
                  &lt;/StackPanel&gt;
              &lt;/HierarchicalDataTemplate&gt;
              &lt;DataTemplate DataType="{x:Type local:SegmentViewModel}"&gt;
                  &lt;DockPanel HorizontalAlignment="Stretch" &gt;
                      &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"&gt;
                          &lt;myUserControl:SegmentLayout HorizontalAlignment="Stretch"/&gt;
                          &lt;TextBlock Text="{Binding Value}"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/DockPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/TreeView.Resources&gt;
          &lt;/TreeView&gt;
          &lt;Button HorizontalAlignment="Left" Content="Add Step" Name="addStepButton" Height="23" Width="103" Grid.Row="1"/&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Oh and before you ask, yes I am basically ripping the SharePoint Workflow designer, this is for an internal tool and for some reason I'm required to write a lightweight workflow engine which is done and a designer for it in WPF that looks very similar to the SP one. I don't make business decisions, just a code monkey ;) .</p>
  
  <p>Many Thanks</p>
  
  <p>Paul</p>