title: How do you use data binding to create a TreeView with infinite depth in WPF?
body: <p>I need to create a TreeView with an infinite parent-child hierarchy. The TreeView needs to be bound to a list named <code>ResourceList</code> and draws its child resources from a list named <code>Children</code>. All the items are the same type.</p>
  
  <p>Here is the XAML code I have so far:</p>
  
  <pre><code>    &lt;TreeView ItemsSource="{Binding ResourceList}" Grid.Column="0" Grid.Row="2" x:Name="ResourcesTree" SelectedItemChanged="ResourcesTree_OnSelectedItemChanged" Margin="0,4,0,0"&gt;
          &lt;TreeView.ItemTemplate&gt;
              &lt;HierarchicalDataTemplate ItemsSource="{Binding Children}"&gt;
                  &lt;TextBlock Text="{Binding Name}" /&gt;
                  &lt;HierarchicalDataTemplate.ItemTemplate&gt;
                      &lt;HierarchicalDataTemplate ItemsSource="{Binding Children}"&gt;
                          &lt;TextBlock Text="{Binding Name}" /&gt;
                          &lt;HierarchicalDataTemplate.ItemTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;TextBlock Text="{Binding Name}" /&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/HierarchicalDataTemplate.ItemTemplate&gt;
                      &lt;/HierarchicalDataTemplate&gt;
                  &lt;/HierarchicalDataTemplate.ItemTemplate&gt;
              &lt;/HierarchicalDataTemplate&gt;
          &lt;/TreeView.ItemTemplate&gt;
      &lt;/TreeView&gt;
  </code></pre>
  
  <p>It works, but the problem is, it only goes three levels deep. What should I change to make it infinite?</p>
  
  <p>In case it's important, I'm using C# and .NET for the code-behind.</p>