17

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

To clarify, take a look at this image:
DataTreeGrid Custom Control

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?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
NemoStein
  • 2,088
  • 2
  • 22
  • 36
  • possible dupe http://stackoverflow.com/questions/1020213/c-can-i-show-an-expandable-tree-like-view-in-a-datagrid, and also http://stackoverflow.com/questions/3457107/wpf-handle-editable-hierarchical-data-treeviewdatagrid-hybrid – xdumaine Mar 31 '11 at 15:43
  • @roviuser, that topic won't answer my question... It even address to the problem directly... But yes, it seems the same scenario... – NemoStein Mar 31 '11 at 15:46

3 Answers3

7

This blog entry from Marius Rochon may help you.

Orace
  • 7,822
  • 30
  • 45
Wegged
  • 2,383
  • 20
  • 26
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

Johan Larsson
  • 17,112
  • 9
  • 74
  • 88
  • 1
    I've found that it handles keyboard navigation (up and down keys) quite strangely. Control from here: http://blogs.msdn.com/b/atc_avalon_team/archive/2006/03/01/541206.aspx should be a drop-in replacement for the control above with proper keyboard handling. – Gman Apr 22 '15 at 21:45
  • 1
    The blog post linked in @Gman's comment is now here: https://learn.microsoft.com/en-us/archive/blogs/atc_avalon_team/treelistview-show-hierarchy-data-with-details-in-columns – Carl Reinke Jun 26 '20 at 17:45
1

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

Rachel
  • 130,264
  • 66
  • 304
  • 490