我有一個Parent和Children屬性的類。WPF TreeView綁定
ADO.NET Entity Framework Hierarchical Page Class http://img148.imageshack.us/img148/6802/edmxxe8.gif
我想在一個WPF樹視圖來顯示這個層次。
這裏是我的XAML ...
<TreeView Margin="12" Name="TreeViewPages" ItemsSource="{Binding}">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type Page}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Path=ShortTitle}" />
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
我的VB代碼...
Dim db As New PageEntities Dim t = From p In db.Page.Include("Children") _ Where p.Parent Is Nothing _ Select p TreeViewPages.ItemsSource = t
,但我得到一棵樹,一個非模板項目:
PageManager.Page
我需要做些什麼來實現這個功能?
查看相關問題:http://stackoverflow.com/questions/269523/how-do-i-use-a-wpf-treeview-hierarchicaldatatemplate-with-linq-to-entities#273535 – 2008-11-07 20:28:19