I am trying to get the name of the property associated with a particular DataGridColumn, so that I can then do some stuff based on that. This function is called whe
No, because DataGridTemplateColumn doesn't inherit from DataGridBoundColumn, so the cast to DataGridBoundColumn would fail.
To make above code work all of your columns must inherit from DataGridBoundColumn abstract class. So making custom derived Column classes instead of DataGridTemplateColumn should work.
You could simply populate a
Dictionary
on initialization and then do
var propName = BoundPropName[dgch.Column]