WPF datagrid header text binding

后端 未结 9 2298
执念已碎
执念已碎 2020-11-27 18:01

The column header of the DataGrid is not a FrameWork element for some reason, and so you cannot use bindings to set things like the header text. Please correct me if that is

9条回答
  •  没有蜡笔的小新
    2020-11-27 18:42

    I used it to populate the DataGrid Column Header.

    Trick is in the binding mode. Its' "Mode" needs to be set to "OneWay". Otherwise it is no good.

    Example:

    
    

    I used a lowercase fallback value, and the value from DataContext was capitalized to assure me that the resource was not null. Also, the value from DataContext was only showing up for me at run time, during design time it displayed the fallback value. Hope this helps.

提交回复
热议问题