title: How to get access to parent's DataContext
body: <p>how can I get access to a parent's DataContext?</p>
  
  <p>I've got an UserControl containing 3 buttons, which I want to use for several different UserControls - so the user has always the same actions available.</p>
  
  <p>When clicked on button 'Add' I need to do something inside the current DataContext, which isn't much of a hassle since I can just do the following:</p>
  
  <pre><code>public void CtrlClicked(object sender, RoutedEventArgs e){
      Button btn = sender as Button;
      MyClass2 c2 = btn.DataContext as MyClass2;
      c2.CallCustomMethod();
  }
  </code></pre>
  
  <p>When the button 'Del' is clicked I want to delete the object <code>MyClass2</code> out of a <code>List&lt;MyClass2&gt;</code> which is held in <code>MyClass1</code>.
  In order to do that I need to have access to MyClass1.</p>
  
  <p>My UI (pseudo code):</p>
  
  <pre><code>Window (DataContext = base)
    Grid
      UserControl uc1 (DataContext = base.MyClass1)
        Grid
          ListView
            ListView.DataTemplate
              UserControl uc2 (DataContext = base.MyClass1.MyClass2)
                Grid
                  UserControl ucButtons
                Grid
              UserControl uc2
            ListView.DataTempate
            ListView.PanelTemplate
              UniformGrid
            ListView.PanelTemplate
          ListView
        Grid
      UserControl uc1
    Grid
  Window
  </code></pre>
  
  <p>So how can I get access to the MyClass1-objext?</p>
  
  <p>I found out that I can walk the tree using <code>.Parent</code>, but can only do that to a certain point:</p>
  
  <pre><code>Grid gScheduleControlBar = btn.Parent as Grid;
  UserControl ucScheduleControlBar = gScheduleControlBar.Parent as UserControl;
  Grid gDay = ucScheduleControlBar.Parent as Grid;
  UserControl ucDay = gDay.Parent as UserControl;
  //ucDay.Name confirms it's the userControl defined
  Grid grid = ucDay.Parent as Grid;
  // grid.Name="" and grid.Parent = null
  </code></pre>
  
  <p>so from here there is no further way upwards, which means I can't pass the <code>UserControl</code> 'border'.</p>
  
  <p>Any ideas?<br>
  As fallback-option there is of course the way of storing a reference of <code>MyClass1</code> in <code>MyClass2</code>.</p>
  
  <p>EDIT => Final Result:<br>
  <code>&lt;Button x:Name="Del" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor AncestorType=UserControl AncestorLevel=3}}"</code></p>