How to add a DataGridTemplateColumn using a button to a WPFToolkit DataGrid that is bound to a DataTable?
Ok, so here is my goal. I have a DataGrid that is going to be bound to a DataTable.
I want to add a DataGridTemplateColumn when the DataContext changes.
For each row, I have an value that is either normal, warning, or error. If normal, I don't want a button on the column at all. If error or warning, I want a button.
So the DataTable looks something like this but in my larger app (this is a minimal example) the data is dynamic in that it can contain different numbers of rows, difference column names, etc. So a static View and static binding isn't going to work.
Field | Value | Compare |
a | 1 | 1 |
b | 2 | 3 |
c | 3 | 5 |
d | 4 | 4 |
So, the idea is to get the WPFToolkit's DataGrid view to look like this. If the numbers differ by 1, it is a warning. If the numbers differ by 2 it is an error.
Field | Value | Compare | Action |
a | 1 | 1 | Normal |
b | 2 | 3 | Warning |
c | 3 | 5 | Error |
d | 4 | 4 | Normal |
I have more complete documentation here of my classes and what I have so far. I have the table displayed, and the buttons create, but I am now lost as to how to:
1. Add text to the buttons
2. Add event for on click to the buttons.
http://rhyous.com/2010/03/18/how-to-add-a-datagridtemplatecolumn-using-a-button-to-a-wpftoolkit-datagrid-that-is-bound-to-a-datatable/[
^]