2010-06-09 42 views
1

我感兴趣的是找出为什么这不工作:的Silverlight树视图不加载子项目

我有一些hierarchicaldatatemplates寻找这样一个TreeView:

<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"/> 

的数据传递到从树视图的DomainService使用这种方法:

public IEnumerable<Subject> GetSubjectList(Guid userid) 
    { 
     DataLoadOptions loadopts = new DataLoadOptions(); 
     loadopts.LoadWith<Root>(s => s.Nodes); 
     this.DataContext.LoadOptions = loadopts; 
     return this.DataContext.Roots; 
    }  

为什么然后仅在树视图中所示,如果它仅装载一个平面列表根节点,而不是一个层级结构,其中根加载NodesCollection?

+0

任何人?我无能为力 – Jakob 2010-06-11 15:38:36

回答

0

这是我的数据。我必须添加[包括]在域服务matadata