在WPF中使用对象分组为treeview创建viewmodel. [英] creation of viewmodel for treeview in WPF with grouping of objects.
问题描述
我正在创建一个用于在WPF(C#.net)中聊天的应用程序.
我创建了一个具有以下属性的类User:
1.Company_name
2.分支
3.名称
4.用户名
我正在获取类用户的对象列表.
我想在树状视图中显示用户为:
公司名称1
-Branch1
-:名称1
-用户名1
-用户名2
-Branch2
-:Designation1
-用户名3
-:Designation2
-用户名4
刷新用户列表时,树结构将重新加载.
我想考虑具有相同父级的用户来创建此树结构.
当新用户登录时,我在运行时获取用户列表.
如何创建这样的树?
我想知道,如何使用ViewModel创建这样的树视图并将其显示在WPF窗口中?
I am creating an application for chatting in WPF(C#.net).
I have created a class User with following attributes:
1.Company_name
2.Branch
3.Designation
4.User_name
I am getting the list of objects of class user.
I want to display the users in treeview as:
Company name1
-Branch1
-:Designation1
-User name1
-User name2
-Branch2
-:Designation1
-User name3
-:Designation2
-User name4
when user list is refreshed, the tree structure will reloaded.
I want to create this tree structure considering users with same parent.
I am getting the user list at run time when a new user logs in.
How to create such tree?
I want to know, how to create such treeview using ViewModel and display it in WPF window??
推荐答案
从Josh Smith在CP上的文章开始:使用ViewModel模式简化WPF TreeView [
Start with Josh Smith''s article here on CP: Simplifying the WPF TreeView by Using the ViewModel Pattern[^]
这篇关于在WPF中使用对象分组为treeview创建viewmodel.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!