I am implementing a WPFToolkit datagrid and I want to bind it to it's source. Currently I do it programatically in code-behind through linking the query results to the ItemsSource . Still this is not effective enough, as I want to be able to select which columns to display and also to rename the headers, for which I need binding for each datagridtextcolumn sections.
I will appreciate any ideas. Thank you in advance!
Best Answer
You can also set the bindings of each column in code-behind.
Here is a sample DataGrid with manually-defined columns with custom header text:
And here is some code-behind that binds each column to a property from the collection that is set to be the ItemsSource:
You can change the header text and visibility in code if you like:
I'm just using a simple test class, Prop, with some string properties.