I want to be able to change the hierarchy in a treeview based on user request. For example, I have a List<vehicles> like this (below) that I want to show in a TreeView.
Ford Red 2-door 2002
Ford Blue 2-door 2003
Jeep Silver 4-Door 2005
Toyota Gray 4-door 2008
Jeep White Hatch 2004
Toyota White 2-door 2001
No big deal until I want to change the grouping, that is, allow make or color or #-doors or year to be the first level in the hierarchy. I don’t see any way to parameterize the binding source in the HierarchicalDataTemplate or use code-behind. What I’d like to end up with is a treeview like this:
+ Ford
Red
Blue
+ Jeep
Silver
White
+Toyota
Gray
White
Or, by a user selection, regroup the treeview to this:
+Red
Ford
+Blue
Ford
+ Silver
Jeep
+Gray
Toyota
+White
Jeep
Toyota
All the data is in a Collection (objects of class vehicle in my example) and ideally, I’d like to be able to group and sort that list using LINQ (perhaps). Any change of implementing this with TreeView?