title: WPF TreeView ItemTemplate alighments
body: <p>i have create my own tree-view with multi column Headers using standard wpf controls</p>
  
  <ul>
  <li>Dock Panel </li>
  <li>DataGrid , Just for creating the columns and having sorting and resizing capabilities. The height of datagrid is only 25 , we only need to show columns not data here.</li>
  <li>The TreeView Control with hierarchy </li>
  </ul>
  
  <p>i have add the image just to understand the problem and the XAML code</p>
  
  <p>The Account Type should be always align at the left no matter how many levels are expanded in the "first column"</p>
  
  <p>somewhere  in the xaml of the TreeViewItemTemplate i lost the idea.. Can anyone help me to fix the alignments   </p>
  
  <p><a href="https://i.stack.imgur.com/Fdqzc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fdqzc.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;DockPanel DataContext="{StaticResource cust}"&gt;
      &lt;Button Command="{Binding rld}" Content="reload" DockPanel.Dock="Top"/&gt;
      &lt;!--Unbound DataGrid just to display the headers--&gt;
      &lt;DataGrid Height="25" DockPanel.Dock="Top" ItemsSource="{Binding Customers}" AutoGenerateColumns="False" Margin="0,0,0,0"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn Binding="{Binding Name}" Header="Name" x:Name="col0"&gt;&lt;/DataGridTextColumn&gt;
              &lt;DataGridTextColumn Binding="{Binding AccountType}" Header="Account Type" x:Name="col1"&gt;&lt;/DataGridTextColumn&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
      &lt;!--Actual Binding with Tree View and item Template to display the properties--&gt;
      &lt;TreeView  ItemsSource="{Binding Customers}" DockPanel.Dock="Top"&gt;
          &lt;TreeView.ItemTemplate&gt;
              &lt;HierarchicalDataTemplate ItemsSource="{Binding rel}"&gt;
                  &lt;Grid  HorizontalAlignment="Stretch"&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="{Binding ElementName=col0,Path=ActualWidth}"&gt;&lt;/ColumnDefinition&gt;
                          &lt;ColumnDefinition Width="{Binding ElementName=col1,Path=ActualWidth}" &gt;&lt;/ColumnDefinition&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;TextBlock  Grid.Column="0" Text="{Binding Name}" VerticalAlignment="Center"/&gt;
                      &lt;TextBlock  Grid.Column="1" Text="{Binding AccountType}"  VerticalAlignment="Center" /&gt;
                  &lt;/Grid&gt;
              &lt;/HierarchicalDataTemplate&gt;
          &lt;/TreeView.ItemTemplate&gt;
      &lt;/TreeView&gt;
  &lt;/DockPanel&gt;
  </code></pre>