Search code examples
wpfdatagridcheckboxselectionchanged

WPF DataGrid SelectionChanged and DataGridCheckBoxColumn


I have a datagrid to which I bind some items. I only allow selecting rows (single item) on this grid.

This grid has a DataGridCheckBoxColumn and a SelectionChanged event.

The problem is that when the user presses a checkbox, it also selects the row (and triggers the SelectionChanged event). This is not the behaviour I would like.

Is there a way I can either prevent the SelectionChanged event from triggering when pressing the checkbox OR detect if was the checkbox column that was pressed in the selectionchanged event?

Thanks!


Solution

  • What about adding a Mouse_Click event on DataGrid row and if it's original source is Checkbox then set e.handled = true otherwise go ahead.