title: Access a WPF TreeViewItem in C# on a double click
body: <p>I want to access a WPF TreeViewItem on a double click. In my WPF it looks like this:</p>
  
  <pre><code>&lt;TreeView x:Name="ExerciseTreeView" Background="#FFF9F9F9" MouseDoubleClick="Exercise_MouseDoubleClick" ScrollViewer.VerticalScrollBarVisibility="Auto"  Grid.Column="2" /&gt;
  </code></pre>
  
  <p>In my C# Code I add the TreeViewItems like this (I have some tasks for a physiotherapy in the lists):</p>
  
  <pre><code>RumpfItem.Header = "Rumpf";
  
  ObereItem.Header = "Obere Extremität";
  
  UntereItem.Header = "Untere Extremität";
  
  DehnenItem.Header = "Dehnen";
  
  FaszienItem.Header = "Faszientraining";
  
  
  
  foreach(var item in Model.Categories_List)
  {
    Task task = Model.Task_List.First(t =&gt; t.TaskID == item.TaskID);
  
    if (item.CategoryID == 1)
    {
      RumpfItem.Items.Add(new TreeViewItem() { Header = task.Name });
    }
    if (item.CategoryID == 2)
    {
      ObereItem.Items.Add(new TreeViewItem() { Header = task.Name });
    }
    if (item.CategoryID == 3)
    {
      UntereItem.Items.Add(new TreeViewItem() { Header = task.Name });
    }
    if (item.CategoryID == 4)
    {
      DehnenItem.Items.Add(new TreeViewItem() { Header = task.Name });
    }
      if (item.CategoryID == 5)
    {
      FaszienItem.Items.Add(new TreeViewItem() { Header = task.Name });
    }
    }
    ExerciseTreeView.Items.Add(RumpfItem);
    ExerciseTreeView.Items.Add(ObereItem);
    ExerciseTreeView.Items.Add(UntereItem);
    ExerciseTreeView.Items.Add(DehnenItem);
    ExerciseTreeView.Items.Add(FaszienItem);
    OpenTrainingPlan_Tab();
  </code></pre>
  
  <p>It shows up correctly but when I do a double click on a TreeViewItem nothing happens. So how can I access the Task I clicked on in my C# Code?</p>