silverlight treeview not loading subitems
Posted
by Jakob
on Stack Overflow
See other posts from Stack Overflow
or by Jakob
Published on 2010-06-09T07:24:43Z
Indexed on
2010/06/16
9:22 UTC
Read the original article
Hit count: 305
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?
© Stack Overflow or respective owner