创建 WPF 混合控件(TreeView + DataGrid = DataTreeGrid)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5502513/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating a WPF Hybrid Control (TreeView + DataGrid = DataTreeGrid)
提问by NemoStein
I need to create a TreeView that hold synchronized data, like a DataGrid.
我需要创建一个保存同步数据的 TreeView,如 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:
所以,我在左侧有一个 TreeView,右侧有一个列。
数据将来自这样的对象:
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?
我怎样才能创建这个?
采纳答案by Wegged
回答by Johan Larsson
回答by Rachel
To me this looks like a regular DataGrid with a few Groupings set on it
对我来说,这看起来像一个普通的 DataGrid,上面设置了一些分组
So in your case you would create a DataGrid that groups on Root, Node #, Node 2nd Number, and Node 3rd Number.
因此,在您的情况下,您将创建一个 DataGrid,它在 Root、Node #、Node 2nd Number 和 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
还将您的 NodeData 列表展平,使其成为单个列表,其中每个项目都包含 Root、NodeLevel1、NodeLevel2 和 NodeLevel3 的属性