0
    <DataGrid x:Name="dataGridShortcuts" AutoGenerateColumns="False" AlternationCount="2" AlternatingRowBackground="#FFADB5B9" Margin="0,0,0,47">
        <DataGrid.Columns>
            <DataGridTextColumn IsReadOnly="True" Binding="{Binding}" Header="Name"/>
            <DataGridCheckBoxColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" />
        </DataGrid.Columns>
    </DataGrid>

when I click the row (any cell), how can I enable/disable the checkbox in the 2nd column?

Currently I have to double click and I read several articles that discuss the first click puts it into editing mode and the second click checks it.

I've also tried

        Style rowStyle = new Style(typeof(DataGridRow));
        rowStyle.Setters.Add(new EventSetter(DataGridRow.MouseDoubleClickEvent,
                                 new MouseButtonEventHandler(Row_DoubleClick)));
        dataGridShortcuts.RowStyle = rowStyle;

and this didn't work either.

software is fun
  • 7,286
  • 18
  • 71
  • 129
  • When the row goes into Edit mode, does it fire any events? If so, trap that one and ignore the mouse. – J.D. Ray May 06 '15 at 18:48
  • That will also put you closer to the goal of (I presume) "enabling the checkbox when the row is selected" by not limiting the method of row selection to using the mouse. – J.D. Ray May 06 '15 at 19:25
  • I am confused about your statement. Can you show me sample code? – software is fun May 06 '15 at 19:47
  • Think about this: why are you pushing your user to use the mouse to select the row, thereby enabling the checkbox? What if they want to use arrow keys and the spacebar? What if they're disabled and need to use alternative input? Write your code so that it targets *what you want to do* rather than *how you imagine your users doing it*. – J.D. Ray May 06 '15 at 19:53
  • For cross-reference: the solution to this question can be found here http://stackoverflow.com/a/7270548/3336376 – M463 Nov 10 '15 at 08:29

1 Answers1

0

This should answer your question, even if I think mouse event handling is the wrong way to go about it.

J.D. Ray
  • 697
  • 1
  • 8
  • 22