I need to bind the column Header text of a DataGrid to a Resource string in a XAML file. Does anybody know if this is possible ?
The column Header definition looks like this but I would like to replace the ‘MyHeaderText’ with text from a resource file:-
<data:DataGridTextColumn Header='MyHeaderText' Binding='{Binding SomeData}' IsReadOnly='True'/>
The Resource string would be set up in the UserControl.Resources section.
The header presentation area is limited. You can achieve this though by utilizing a string instead of a UIElement. Make sure you have the xmlns for the ‘System’ namespace in your xaml file like so:
Then have the following defined in your UserControl’s Resources section:
Then you can do basically what Sorskoot said and you shouldn’t receive an error: