title: WPF Complex TreeView
body: <p>I am trying to create a TreeView structure with different object types in it. It is basically like the solution explorer of Visual Studio (Solution with Projects under it and under project there are Properties, References, Folders etc. with each having different context menu and TreeView gets updated when underlying structure gets changed ex: added new file.)</p>
  
  <p>I have a project object. Which have Name, Path and List of other objects (input files, output files etc. which are custom classes).</p>
  
  <p>I would like to display it as a structure on a TreeView with specific ContextMenues and double click events based on their type. </p>
  
  <pre><code>Project_Name
  |-Inputs =&gt; ContextMenu =&gt; Add =&gt; opens dialog to add a new input file
  |  |-Input1 =&gt; Double click will open a dialog to edit this input file
  |  |-Input2
  |  |-...
  |-Outputs
     |-Output1 =&gt; Double click will open a dialog to edit this output file 
     |-Output2
  </code></pre>
  
  <p>Lets say I add a new input file by using context menu to open new input file dialog and once I am done I want the TreeView to be updated to show that input file as well. </p>
  
  <hr>
  
  <h2>UPDATE 1</h2>
  
  <p>I have created some HierarchicalDataTemplates </p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;HierarchicalDataTemplate DataType="{x:Type project:ETLProject}" ItemsSource="{Binding Path=InputDefinitions}"&gt;
          &lt;TextBlock Text="Project"/&gt;
      &lt;/HierarchicalDataTemplate&gt;
      &lt;HierarchicalDataTemplate DataType="{x:Type inputdef:InputDefinition}" ItemsSource="{Binding Path=Columns}"&gt;
          &lt;TextBlock Text="{Binding Path=Name}"/&gt;
      &lt;/HierarchicalDataTemplate&gt;
      &lt;DataTemplate DataType="{x:Type column:Column}"&gt;
          &lt;TextBlock Text="{Binding Path=Name}"/&gt;
      &lt;/DataTemplate&gt;
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>And I have the following TreeView</p>
  
  <pre><code>&lt;TreeView Margin="5" Name="ProjectTreeView"&gt;
  &lt;/TreeView&gt;
  </code></pre>
  
  <p>When a project is loaded I set the DataContext of ProjectTreeView to the project object. However I do not see anything on the UI. When I change it to </p>
  
  <pre><code>&lt;TreeView Margin="5" Name="ProjectTreeView" ItemsSource="{Binding Path=InputDefinitions}"&gt;
  &lt;/TreeView&gt;
  </code></pre>
  
  <p>I am able to see input definitions and columns as their children. </p>
  
  <p>So how can I manage to make it project => input definitions => columns</p>