WPF Binding with RelativeSource and AncestorType

Viewed 27271

I have a WPF application. It has a grid that is split into 4 rows. In the 2 row I have a datagrid that has its datacontext set to an object of OrderBlock. This all works fine. However I would like one of the column header text value of the datagrid be bound to a property in my view model.

Below is an example of what I have tried unsuccessfully.

<DataGridTextColumn Header="{Binding RelativeSource={RelativeSource 
   AncestorType={x:Type Window}}, Path=ColumnHeadInfo}" 
   Binding="{Binding RejectReason}" IsReadOnly="True"/>
2 Answers
Related