title: XAML Binding to parent of data object
body: <p>I have a grid column defined. The parent grid gets its items from an ObservableCollection of type ItemClass. ItemClass has two properties: String Foo, and bool IsEditAllowed. </p>
  
  <p>This column is bound to property Foo. There's a control template for editing the cell. I'd like to bind the ItemClass.IsEditAllowed property to the IsEnabled property of the TextBox in the template. </p>
  
  <p>The question is how to bind it. Can this be done? The XAML below gets me "Cannot find source for binding with reference" in the debug trace. </p>
  
  <p>The grid will let me bind the ItemClass itself to the field via some "custom" event thingy, and I can then bind to any of its properties. That's fine, but it seems kludgy. But if it's the only way, it's the only way. </p>
  
  <pre><code>&lt;dxg:GridColumn
                   Header="Foo Column"
                   FieldName="Foo"&gt;
      &lt;dxg:GridColumn.EditTemplate&gt;
          &lt;ControlTemplate&gt;
              &lt;TextBox Text="{Binding Value, Mode=TwoWay}"
                       IsEnabled="{Binding Path=IsEditAllowed, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ItemClass}, AncestorLevel=1}}" /&gt;
          &lt;/ControlTemplate&gt;
      &lt;/dxg:GridColumn.EditTemplate&gt;
  &lt;/dxg:GridColumn&gt;
  </code></pre>