title: Binding TreeView with a ObservableCollection
body: <p>I'm making a player in C#, by using Visual Studio 2010.
  I'm looking for a way to display a playlist of files.
  So I'm using a TreeView, and I want to bind it with an ObservableCollection.
  My ObservableCollection :</p>
  
  <pre><code>public class Media
  {
   string type; // Video, music, or picture
   string name; // example : 50-cent.mp3
   string path; // The path of the file
  }
  
  public class Playlist 
  {
   string name; // The name of the playlist
   ObservableCollection&lt;Media&gt; list; // The list of Media
  }
  public ObservableCollection&lt;Playlist&gt; playLists = new ObservableCollection&lt;Playlist&gt;();
  </code></pre>
  
  <p>As you see, I have the var playlists, inside there are elements, and inside them, there are list of media. </p>
  
  <p>I want to show this object in the wpf, and I think the best is TreeView.
  I can't find in internet the way for binding TreeView and my var playlists.
  I don't know how to make my TreeView in my WPF :S ... 
  I read in internet that some people use HierachicalDataTemplate, but I really don't know how to do that exactly.</p>
  
  <p>Help please</p>
  
  <p><strong>EDIT
  I'm trying the post given by David, I put my WPF</strong></p>
  
  <pre><code>&lt;TreeView Grid.Column="1" Height="193" HorizontalAlignment="Left" Margin="15,209,0,0" Name="treeView1" VerticalAlignment="Top" Width="120"&gt;
          &lt;TreeView.Resources&gt;
              &lt;HierarchicalDataTemplate DataType="{x:Type src:Playlist}" ItemsSource="{Binding list}"&gt;
                  &lt;TextBlock Text="{Binding name}"/&gt;
              &lt;/HierarchicalDataTemplate&gt;
              &lt;DataTemplate DataType="{x:Type src:Media}"&gt;
                  &lt;TextBlock Text="{Binding name}"/&gt;
              &lt;/DataTemplate&gt;
          &lt;/TreeView.Resources&gt;
      &lt;/TreeView&gt;
  </code></pre>
  
  <p>I have problem, I still have nothing :S .
  I did exactly like the tutorial :S</p>