I have a node class I’m trying to use to populate a TreeView in Silverlight:
class TreeNode {
public string Caption {get; set;};
public IEnumerable<TreeNode> Children{get; set;}
}
My XAML is as follows:
<controls:TreeView VerticalAlignment="Stretch"
x:Name="trv"
Height="150" >
<controls:TreeView.ItemTemplate>
<common:HierarchicalDataTemplate ItemsSource="{Binding Path=Children}" >
<TextBlock Text="{Binding Path=Caption}" />
</common:HierarchicalDataTemplate>
</controls:TreeView.ItemTemplate>
</controls:TreeView>
However, only the first tier of elements load. If I replace TextBlock with HerarchicalDataTemplate, basically hard-coding my data depth, the 2nd tier of elements are displayed. However then the 3rd tier are not.
Any ideas?
I just tried this out, you must be doing something wrong on the data binding part, since everything is working as expected. I created a simple example with your XAML below.
Output:
XAML:
Code: