silverlight treeview not loading subitems
- by Jakob
I'm interested in finding out why this isn't working:
I have a treeview with some hierarchicaldatatemplates looking like this:
<UserControl.Resources>
<sdk:HierarchicalDataTemplate x:Key="nodeEntry">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Title}" />
</StackPanel>
</sdk:HierarchicalDataTemplate>
<sdk:HierarchicalDataTemplate x:Key="rootEntry"
ItemsSource="{Binding Path=Nodes}" ItemTemplate="{StaticResource nodeEntry}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" />
</StackPanel>
</sdk:HierarchicalDataTemplate>
</UserControl.Resources>
<sdk:TreeView Height="250" HorizontalAlignment="Left"
ItemTemplate="{StaticResource rootEntry}"
ItemsSource="{Binding ElementName=subjectDomainDataSource, Path=Data}"
Name="rootTreeView" VerticalAlignment="Top" Width="180"/>
The data is passed to the treeview from a domainservice using this method:
public IEnumerable<Subject> GetSubjectList(Guid userid)
{
DataLoadOptions loadopts = new DataLoadOptions();
loadopts.LoadWith<Root>(s => s.Nodes);
this.DataContext.LoadOptions = loadopts;
return this.DataContext.Roots;
}
why then are only the root nodes shown in the treeview as if it only loaded a flat list, and not a hierarchy where the root Loads the NodesCollection?