I am trying to build a TreeView and have it set up like this link:
Silverlight vs WPF – Treeview with HierarchialDataTemplate
As a comment to the first actual answer provided the poster says how they solved it but they didn’t provide code and I understand what they said but I am really new to this and can’t get it right. I have the same set-up structure with the entities and groups. I was wondering if some one could explain what the xaml ended up looking like. I am assuming by saying they made a new node class it just means they made a class that contains essentially a list of groups. Something like
class groupHolder
{
public List<Group> myGroups {get;set;}
public groupHolder() { myGroups = new List<Group>(); }
}
I am just trying to go three levels deep:
Group 1
– – – – AnotherGroup1
– – – – – – – – entity1
– – – – – – – – entity2
– – – – AnotherGroup2
– – – – – – – – entity1
Group2
– – – – Entity1
– – – – Entity2
– – – – AnotherGroup1
– – – – – – – – entity1
– – – – – – – – entity2
– – – – AnotherGroup2
– – – – – – – – entity1
and so on…
Like I said, I am new to this. I’ve also been trying to use this tutorial:
but when I try and set another HierarchicalDataTemplate it says that ItemTemplate is set more than once. I’m lost.
edit: found this link on the web, it helps, too…. I think…
http://www.codeproject.com/Articles/36451/Organizing-Heterogeneous-Data-on-a-WPF-TreeView.aspx
I was able to re-create that structure:
TreeView:
Templates:
In the ViewModel I have:
Rest: