How can I find the DataGridTextColumn from the HeaderTemplate template? Is there a way to perform this using only XAML? I have tried FindAncestor of type DataGridTextColumn but it is not found.
I know DataGridTextColumn is not part of the visual tree. Is there any workaround for this?
Do you really need the whole column object? The DataContext will be whatever you pass in as header, e.g.
This will cause a red header with the text “Name”.
If you actually need the column you could use an
ElementNamebinding:This shows “Name” and the column width in the header.