title: TextBox, Button and ListBox in a ListBox
body: <p>I have a listbox with a bunch of contols in each list item.</p>
  
  <pre><code>&lt;ListBox x:Name="projectList" IsSynchronizedWithCurrentItem="True"&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;StackPanel&gt;
                  &lt;TextBlock Text="{Binding Name}" /&gt;
                  &lt;ListBox x:Name="taskList" ItemsSource="{Binding Tasks}"&gt;
                      &lt;ListBox.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;StackPanel&gt;
                                  &lt;TextBlock Text="{Binding Name}" /&gt;
                              &lt;/StackPanel&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ListBox.ItemTemplate&gt;
                  &lt;/ListBox&gt;
                  &lt;TextBox x:Name="textBoxTask" /&gt;
                  &lt;Button
                      x:Name="ButtonAddNewTask"
                      Content="Test"
                      CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext}"
                      Click="ButtonAddNewTask_Click"
                      /&gt;
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>When I click on the button in the listbox i want to add a new item to the listbox within the listbox. I've come this far. So my question is how do I get hold of the textbox and how do I update the listbox?</p>
  
  <p>Here is my click event</p>
  
  <pre><code>private void ButtonAddNewTask_Click(object sender, RoutedEventArgs e)
  {
      Button button = (Button)sender;
      Project proj = button.DataContext as Project;
      if(proj.Tasks == null)
          proj.Tasks = new List&lt;Task&gt;();
  
      proj.Tasks.Add(new Task("Added Task"));
  }
  </code></pre>
  
  <p>Thanx</p>