我正在尝试使用链接对数据进行分组并直接在 treeview1.itemsource 中使用它。我使用的代码是:
DisksTreeView1.ItemsSource = (From g As Classes.DiskPrime In CurrentVariables.DisksList
Group By g.Genre
Into MyGroup = Group)
Xaml 是:
<TreeView Name="DisksTreeView1" >
<TreeView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Namee}" />
</DataTemplate>
</TreeView.ItemTemplate>
</TreeView>
类代码是:
Public Class DiskPrime
Property ID As String
Property Namee As String
Property Genre As String
Property DateCreated As Date
Property Path As String
End Class
运行程序后,我只得到一个空白的树视图,请您纠正我做错的地方。谢谢你。