I have a DataGrid
in a WPF form with a DataGridCheckBoxColumn
, but I did not find any click event, Checked and unchecked for it...
Are these events available for the DataGridCheckBoxColumn
? If not please suggest some workaround I could use.
I have a DataGrid
in a WPF form with a DataGridCheckBoxColumn
, but I did not find any click event, Checked and unchecked for it...
Are these events available for the DataGridCheckBoxColumn
? If not please suggest some workaround I could use.
Quoted from William Han's answer here: http://social.msdn.microsoft.com/Forums/ar/wpf/thread/9e3cb8bc-a860-44e7-b4da-5c8b8d40126d
It simply adds an event to the column. It is a good simple solution.
How about something like this.
Then in XAML
One note with this approach, however, is you may run into issues with virtualization and checked items not clearing (not sure, haven't tested with SelectionMode="Single"). If that is the case, the simplest workaround I have found to work is to turn virtualization off, but perhaps there is a better way to get around that particular issue.
Expanding on the DataGridCell concept noted above, this is what we used to get it working.
...XAML...
TheMissingChildren is an ObservableCollection object that contains the list of data elements including a boolean field "Checked" that we use to populate the datagrid.
The SelectionChanged code here will set the checked boolean in the underlying TheMissingChildren object and fire off a refresh of the items list. That ensures that the box will get checked off & display the new state no matter where you click on the row. Clicking the checkbox or somewhere in the row will toggle the check on/off.