title: TreeView, HierarchicalDataTemplate and recursive Data
body: <p>For my treeview I have two different classes that provide the ItemsSource.</p>
  
  <pre><code>public class TreeViewModel : ViewModelBase
  {
      public ObservableCollection&lt;NodeViewModel&gt; Items { get; set; }
  }
  
  public class NodeViewModel : ViewModelBase
  {
      public string Id { get; set; }
      public string Name { get; set; }
      public ObservableCollection&lt;NodeViewModel&gt; Children { get; set; }
  }
  </code></pre>
  
  <p>Now I want my TreeView to display the Items in TreeViewModel and show hierarchical data as provided by the NodeViewModel.</p>
  
  <p>Here is my XAML</p>
  
  <pre><code>&lt;Window x:Class="TreeViewMasterDetails.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:local="clr-namespace:TreeViewMasterDetails" 
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;TreeView Height="Auto" 
                    HorizontalAlignment="Stretch" 
                    Margin="10" 
                    VerticalAlignment="Stretch" 
                    Width="Auto"&gt;
              &lt;TreeView.Resources&gt;
                  &lt;HierarchicalDataTemplate DataType="x:Type local:TreeViewModel" ItemsSource="{Binding Items}"&gt;
                      &lt;TextBlock Text="{Binding Path=Name}"&gt;&lt;/TextBlock&gt;
                  &lt;/HierarchicalDataTemplate&gt;
                  &lt;HierarchicalDataTemplate DataType="x:Type local:NodeViewModel" ItemsSource="{Binding Children}"&gt;
                      &lt;TextBlock Text="{Binding Name}"&gt;&lt;/TextBlock&gt;
                  &lt;/HierarchicalDataTemplate&gt;
              &lt;/TreeView.Resources&gt;
          &lt;/TreeView&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Have tried to provide <code>Items</code> as the <code>ItemsSource</code> of the <code>TreeView</code>.
  It does not show the data hierarchically, if displaying anything.</p>
  
  <p>And I tried using the <code>ItemTemplate</code> instead of the <code>TreeView.Resources</code>, too.</p>
  
  <p>What is wrong about it?</p>
  
  <p>Perhaps a problem is the first <code>TextBlock Text Binding</code>? 
  I want to display the <code>Name</code> property of the <code>NodeViewModel</code> in <code>Items</code> there.</p>