title: Silverlight 4: Binding ChildControl to ParentControl
body: <p>Within a TabItem Style I have a Button. That Button has a command, which I would like to send the (Parent) TabItem to. In Silverlight we don't have RelativeSource. But I can't simply use Elementname neither. because my TabItem has no name within the style. </p>
  
  <pre><code>&lt;Style TargetType="sdk:TabItem"&gt;
                          &lt;Setter Property="HeaderTemplate"&gt;
                              &lt;Setter.Value&gt;
                                  &lt;DataTemplate&gt;                                  
                                      &lt;StackPanel Orientation="Horizontal"&gt;                                        
                                          &lt;TextBlock Text="{Binding TabCaption}"/&gt;
                                          &lt;Button Margin="8,0,0,0" 
                                                  Command="local:Commands.CloseTabItem" 
                                                  CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type sdk:TabItem}}}" 
                                                  HorizontalContentAlignment="Center" 
                                                  VerticalContentAlignment="Center"&gt;                                            
                                          &lt;/Button&gt;
                                      &lt;/StackPanel&gt;
                                  &lt;/DataTemplate&gt;
                              &lt;/Setter.Value&gt;
                          &lt;/Setter&gt;
                      &lt;/Style&gt;
  </code></pre>
  
  <p>This would be the code within the Command's method:</p>
  
  <pre><code>private void OnCloseTabItemExecute(object sender, ExecutedRoutedEventArgs e)
  {
      TabItem parent = e.Parameter as TabItem;
  
      if (parent != null)
      {
          FrameworkElement view = (parent as TabItem).Content as FrameworkElement;
          string regionName = RegionManager.GetRegionName(view);
  
          _regionManager.Regions[regionName].Remove(view);
      }
  }
  </code></pre>
  
  <p>How could I pass in the parent Control (TabItem) as the child control's command Parameter in Silverlight 4?</p>
  
  <p>highly Appreciated.</p>