title: Can't find the parent of a templated control by type(!) (wpf)
body: <p>In my WPF project I have a bit complex control. In the project I only use Controls (they're all templated), besides MainWindow.</p>
  
  <p>On one screen I have the following layout (for showing the layout after templates have been applied and contents filled):</p>
  
  <p>MyScreenControl<br/>
  -MyTableControl<br/>
  --ItemsControl<br/>
  --- HeaderItemsControl<br/>
  -----HeaderItemsControl.Header<br/>
  ------MyHeaderControl<br/>
  -----HeaderItemsControl.Items<br/>
  ------MyItemControl<br/>
  ------MyItemControl<br/>
  ------MyItemControl<br/>
  ...<br/></p>
  
  <p>When I'm in the ScreenControl's code file, in the OnMouseLeftButtonDown method I would like to determine if the click event came from a MyHeaderControl or a MyItemControl.</p>
  
  <p>The MouseButtonEventArgs's Source is the ScreenControl and the OriginalSource is the TextBlock in the MyItemControl/MyHeaderControl 's template.</p>
  
  <p>My first attempt to find the MyItemControl/MyHeaderControl was to start from the OriginalSource and recursively look at the type of the Parent property. It works fine till I get to the root of the Template (which is in this case a ViewBox), but the root has no Parent element.</p>
  
  <p>I've used a method like this in az earlier project of mine and it worked, but then I was working with UserControls, not Controls, nor Templates.</p>
  
  <p>Any ideas how should I approach this problem (a good idea is as wellcome as a code)?</p>
  
  <p>thx,
  Tenshiko</p>