title: WPF - XAML Treeview to Generic.List binding
body: <p>I am trying to bind an IList to a WPF TreeView in a hierarchal display. Here is my object:</p>
  
  <pre><code>public class TeamsTreeViewItem
   {
    public string DisplayValue { get; set; }
    public string KeyValue { get; set; }
  
    readonly List&lt;TeamsTreeViewItem&gt; children = new List&lt;TeamsTreeViewItem&gt; ();
  
    public IList&lt;TeamsTreeViewItem&gt; Children
    {
     get
     {
      return children;
     }
    }
  
    public override string ToString ()
    {
     return DisplayValue;
    }
   }
  </code></pre>
  
  <p>I don't know how many children a particular object will have, and the children might have children too.</p>
  
  <p>I am fussing around with my HierarchialDataTemplate, but not being successful:</p>
  
  <pre><code>    &lt;TreeView Canvas.Left="263" Canvas.Top="12" Height="200" Name="TeamTreeView" Width="120"&gt;
          &lt;TreeView.Resources&gt;
              &lt;HierarchicalDataTemplate  DataType="{x:Type local:TeamsTreeViewItem}" ItemsSource="{Binding DisplayValue}" &gt;
                  &lt;TextBlock Text="{Binding DisplayValue}"/&gt;
              &lt;/HierarchicalDataTemplate&gt;
              &lt;HierarchicalDataTemplate  DataType="{x:Type local:TeamsTreeViewItem}" ItemsSource="{Binding Children}" &gt;
                  &lt;TextBlock Text="{Binding DisplayValue}"/&gt;
              &lt;/HierarchicalDataTemplate&gt;
          &lt;/TreeView.Resources&gt;
      &lt;/TreeView&gt;
  </code></pre>
  
  <p>Any suggestions?</p>