title: Grouping child objects in WPF TreeView
body: <p>I am trying to get my tree view to group a collection of similar items by what they are. To keep things generic, my object hierarchy could look like this:  </p>
  
  <ul>
  <li>Objects  
  
  <ul>
  <li>Object Group #1  
  
  <ul>
  <li>Item #1 (Type 'A')  </li>
  <li>Item #2 (Type 'A')  </li>
  <li>Item #3 (Type 'B')  </li>
  <li>Item #4 (Type 'B')  </li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>Right now my TreeView shows these objects exactly like the object model, but what I would like to do is insert a TreeView node for each object type so that it would look like this:  </p>
  
  <ul>
  <li>Objects  
  
  <ul>
  <li>Object Group #1  
  
  <ul>
  <li>Type A  
  
  <ul>
  <li>Item #1  </li>
  <li>Item #2  </li>
  </ul></li>
  <li>Type B  
  
  <ul>
  <li>Item #3  </li>
  <li>Item #4  </li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>I saw in a similar question here that someone recommended to have two separate <code>HierarchicalDataTemplates</code> so I created one for 'Object Group #1' level which contains a TreeView with a list of the types, but this is really clumsy since it is a whole separate TreeView inside of some nodes. I have also been trying to use a <code>CollectionViewSource</code> to filter out the items in each category, but this doesn't do me very much good since I can't figure out how to display them.</p>
  
  <p>I guess my question boils down to this: How do I make a <code>HierarchicalDataTemplate</code> group it's children? If someone could point me in the right direction I would appreciate it a lot.  </p>
  
  <p>I can post some code if anyone wants to see, but I am really just trying to figure out how to do what I want so my code is just a pretty straight forward databound treeview right now.</p>