Creating a WPF Hybrid Control (TreeView + DataGrid = DataTreeGrid)

为君一笑 提交于 2019-12-18 10:44:51

问题


I need to create a TreeView that hold synchronized data, like a DataGrid.

To clarify, take a look at this image:

So, I have a TreeView at left side with columns at right side.
The data will come from objects like this:

public NodeData Parent;
public List<NodeData> Children;

public String Label;

public Boolean DataA;
public Boolean DataB;
public Boolean DataC;
public Boolean DataX;
public Boolean DataY;
public Boolean DataZ;

How can I create this?


回答1:


http://blogs.msdn.com/b/mrochon/archive/2009/10/16/displaying-hierarchical-data-in-the-datagrid.aspx




回答2:


This is the best control I have found for presenting data like this. It does not require an interface/basclass on the viemodels and uses HierarchicalDataTemplate




回答3:


To me this looks like a regular DataGrid with a few Groupings set on it

So in your case you would create a DataGrid that groups on Root, Node #, Node 2nd Number, and Node 3rd Number.

Also flatten your list of NodeData so it is a single list with each item containing properties for Root, NodeLevel1, NodeLevel2, and NodeLevel3



来源:https://stackoverflow.com/questions/5502513/creating-a-wpf-hybrid-control-treeview-datagrid-datatreegrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!