WPF将数据表绑定到树视图 [英] WPF Binding a DataTable to Tree View
本文介绍了WPF将数据表绑定到树视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下数据表.
id父级ID类别级别
---------------------------------------
1 0主要0
2 1饮料1
3 2软饮料2
4 3百事可乐3
我必须像这样在WPF中显示树.
小学
->饮料
->软饮料
->百事可乐
请帮我一些代码片段.
谢谢与问候
Monish KM
i am having following data table.
id parent Id Category Level
---------------------------------------
1 0 Primary 0
2 1 Drinks 1
3 2 Soft drinks 2
4 3 Pepsi 3
I have to Show tree in WPF like this.
Primary
--> Drinks
--> Soft drinks
--> Pepsi
Please help me out with some code snippets.
Thanks & Regards
Monish K.M
推荐答案
使用 MSDN:HierarchicalDataTemplate类 [ ^ ]应该会有所帮助.
以下应该会有所帮助,看看并尝试:
^ ]
使用ViewModel模式简化WPF TreeView [ ^ ]
皮特(Pete)详细回答了类似的问题: WPF:如何从数据库填充TreeView [ ^ ]
Using MSDN: HierarchicalDataTemplate Class[^] should help.
Following should help, have a look and try:
A TreeView, a HierarchicalDataTemplate, and a 2D collection walk into a bar ...[^]
Simplifying the WPF TreeView by Using the ViewModel Pattern[^]
Similar Question answered in detail by Pete: WPF : How to Fill TreeView from DataBase[^]
这篇关于WPF将数据表绑定到树视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文