12

WPF's DataGrid requires a double click to enter cell editing mode, and then the user can change the checkbox value.

How to make a cell editable without requiring the double click for entering the edit mode?

Jader Dias
  • 88,211
  • 155
  • 421
  • 625
  • 1
    possible duplicate of [wpf datagrid enter to edit](http://stackoverflow.com/questions/6336868/wpf-datagrid-enter-to-edit) – Jader Dias Mar 01 '12 at 16:52

1 Answers1

13

Just think of using a CheckBox directly in your CellTemplate.

<DataGridTemplateColumn Header="Your boolean column">
  <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
          <CheckBox IsChecked="{Binding YourBooleanProperty, UpdateSourceTrigger=PropertyChanged}" />
      </DataTemplate>
  </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
Markus
  • 4,487
  • 3
  • 41
  • 51
  • @XMLforDummies: Setting UpdateSourceTrigger is possible, but not really necessary in this case. It is more common if you are using a TextBox. – Markus Mar 02 '12 at 12:22
  • 1
    Actually, I was not able to get this to work without the UpdateSourceTrigger specification. – Paul Keister Apr 11 '13 at 00:31
  • The above solution enables (de-)selecting checkbox with a single mouse click, but the column loses the ability to be selected by keyboard (space bar) :| – Paweł Bulwan Jun 30 '22 at 07:26