title: Avoid Breaking MVVM with TreeView and HierarchicalDataTemplate
body: <p>I have an application which I am trying to design using the MVVM pattern. In my Models I have Group and Case. A Group may contain other groups as well as cases. Now, I want to display these in a TreeView in my View. So because Groups may contain other groups and cases, the tree can end up looking something like this:<br/>
  <strong>Group</strong><br/>
  --<strong>Group</strong><br/>
  ----<em>Case</em><br/>
  ----<em>Case</em><br/>
  --<strong>Group</strong><br/>
  ----<strong>Group</strong><br/>
  ----<em>Case</em><br/>
  --<em>Case</em><br/>
  <em>Case</em></p>
  
  <p>I have my View attached to a ViewModel which contains an ObservableCollection of Groups. My problem is that the only way I can get the TreeView to display as I would like it to is to use a HierarchicalDataTemplate in the resources pointed to the datatype (Group or Case), which I feel like is breaking MVVM (where the View should not know about the Model).</p>
  
  <p>This works:</p>
  
  <pre><code> &lt;UserControl.Resources&gt;
      &lt;HierarchicalDataTemplate DataType="{x:Type models:Group}" ItemsSource="{Binding Children}"&gt;
          &lt;TextBlock Text="{Binding GroupName}" /&gt;
      &lt;/HierarchicalDataTemplate&gt;
      &lt;DataTemplate DataType="{x:Type models:Case}"&gt;
          &lt;TextBlock Text="{Binding CaseName}" /&gt;
      &lt;/DataTemplate&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>and for the TreeView:</p>
  
  <pre><code>&lt;TreeView ItemsSource="{Binding AvailableCaseGroups}" /&gt;
  </code></pre>
  
  <p>Is this breaking the spirit of MVVM? How can I do this otherwise?</p>