I have DataTemplateone that I use both CellTemplatefor GridViewColumn.
I want to write something like this for DataTemplate:
<DataTemplate
x:Key="_myTemplate">
<TextBlock
Text="{Binding Path={Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GridViewColumn}}, Path=Header}}" />
</DataTemplate>
My is GridViewbound to DataTable, and I want to bind to a column DataTablewhose name is equal to the header GridViewColumnto which it is bound DataTemplate. [Hope this made sense!]
Unfortunately this does not work. I get a XamlParseException: "A Binding" cannot be set in the "Path" property of type "Binding". Binding can only be set to the DependencyProperty of the DependenceyObject. "
How can I customize this?
Edit (add DanM comment to the question)
DataTemplate, DataContext DataTemplate. ?