title: How bind an object to treeview from Xaml
body: <p>I am trying to bind an object to the treeviewcontrol WPF by XAML, I am getting the treview as empty. When i am doing that by <code>treeview.items.add(GetNode())</code> then its working.</p>
  
  <p>I am using MVVM Framework(caliburn.Micro) I wanted to do it in Xaml, how do I assign Item source property in xaml? I tried with creating a property of Node class and calling the Method GetNode() with in the property, and assigned that property as itemssource of the treeview and changed the List to Observable collection. Still issue is same.</p>
  
  <p>Working Xaml when doing <code>treeview.items.Add(GetNode())</code> which returns a Node and and <code>i</code> as assigning Nodes collection to Hireachial Template.</p>
  
  <pre><code>&lt;TreeView  Name="treeview2" 
              Grid.RowSpan="2"
              Grid.ColumnSpan="2"
              ItemContainerStyle="{StaticResource StretchTreeViewItemStyle}" Width="300"&gt;
              &lt;TreeView.ItemTemplate&gt;
                   &lt;HierarchicalDataTemplate  ItemsSource="{Binding Nodes}"&gt;
                        &lt;DockPanel LastChildFill="True"&gt;
                            &lt;TextBlock  Padding="15,0,30,0" Text="{Binding Path=numitems}" TextAlignment="Right" 
      DockPanel.Dock="Right"/&gt;
                            &lt;TextBlock  Text="{Binding Path=Text}" DockPanel.Dock="Left" TextAlignment="Left" /&gt;
                        &lt;/DockPanel&gt;
                   &lt;/HierarchicalDataTemplate&gt;
              &lt;/TreeView.ItemTemplate&gt;
    &lt;/TreeView&gt;
  </code></pre>
  
  <p>Server Side Code:</p>
  
  <pre><code>this.treeview2.Items.Add(GetNode());
  </code></pre>
  
  <p>GetNode recursively build a list of type Node.</p>
  
  <pre><code>public class Node
  {
      public string Text { get; set; }
      public List&lt;Node&gt; Nodes { get; set; }
      public ObservableCollection&lt;Node&gt; Nodes{get;set;} // with list and observable collection same results
      public int numitems { get; set; }
  }
  </code></pre>