title: Access parent DataContext from DataTemplate
body: <p>I have a <code>ListBox</code> which binds to a child collection on a ViewModel. The listbox items are styled in a DataTemplate based on a property on the parent ViewModel:</p>
  <pre><code>&lt;Style x:Key=&quot;curveSpeedNonConstantParameterCell&quot;&gt;
     &lt;Style.Triggers&gt;
        &lt;DataTrigger Binding=&quot;{Binding Path=DataContext.CurveSpeedMustBeSpecified, 
            ElementName=someParentElementWithReferenceToRootDataContext}&quot; 
            Value=&quot;True&quot;&gt;
            &lt;Setter Property=&quot;Control.Visibility&quot; Value=&quot;Hidden&quot;&gt;&lt;/Setter&gt;
        &lt;/DataTrigger&gt;
     &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  <p>I get the following output error:</p>
  <pre><code>System.Windows.Data Error: 39 : BindingExpression path error: 
   'CurveSpeedMustBeSpecified' property not found on 
     'object' ''BindingListCollectionView' (HashCode=20467555)'. 
   BindingExpression:Path=DataContext.CurveSpeedMustBeSpecified; 
   DataItem='Grid' (Name='nonConstantCurveParametersGrid');
   target element is 'TextBox' (Name=''); 
   target property is 'NoTarget' (type 'Object')
  </code></pre>
  <p>So if I change the the binding expression to <code>&quot;Path=DataContext.CurrentItem.CurveSpeedMustBeSpecified&quot;</code> it works, but only as long as the DataContext of the parent user control is a <code>BindingListCollectionView</code>. This is not acceptable because the rest of the user control binds to the properties of the <code>CurrentItem</code> on the <code>BindingList</code> automatically.</p>
  <p><b>How can I specify the binding expression inside the style so that it works regardless of the parent data context being a collection view or a single item?</b></p>