We need to solve the following issue:
- a DataTable is used as datasource
- a new column must be inserted in the data table, with type bool, allowing the user to mark a row as “header row”
- a “header row” is displayed with a different style
- the user can check and uncheck any row; the code must ensure at most one row is marked as “header row” at a certain moment
The last issue I’ve run into: the DataTable object is not observable and the header style is not applied when the user checks a row.
I’ve implemented an observable collection over the DataTable, however I cannot use the AutoGenerateColumns property: instead of generating columns, the DataGrid generates only one column of type Collection.
Links I’ve studied so far:
http://www.reimers.dk/jacob-reimers-blog/auto-generating-datagrid-columns-from-dynamicobjects : this one may be the most important: use a PropertyDescriptor to describe the properties you want to be used when generating the columns.
May need to implement ICustomTypeDescriptor as well.
Another option (probably the best one – long live Boggie!): use a RowHeaderTemplate!
How to add columns programmatically (with a behavior): http://stackoverflow.com/questions/320089/how-do-i-bind-a-wpf-datagrid-to-a-variable-number-of-columns
Styling cheat sheet: https://blogs.msdn.microsoft.com/jaimer/2009/01/20/styling-microsofts-wpf-datagrid/