WPF - How to bind a DataGridTemplateColumn

后端 未结 5 667
予麋鹿
予麋鹿 2021-02-05 07:07

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

5条回答
  •  别那么骄傲
    2021-02-05 07:33

    1. 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.

    2. You could simply populate a

      Dictionary BoundPropName;

      on initialization and then do

      var propName = BoundPropName[dgch.Column]

提交回复
热议问题