I use a DataGrid
with a CheckBoxColumn
in c# 4.0. right now I need 2 clicks to change the state of a CheckBox
if I enable row selection.
One click selects the row and the second changes the state of the CheckBox
. How can I enable row selection, but keep the 1 click for changing the state of the CheckBoxColumn
?
<DataGrid AutoGenerateColumns="False"
SelectionMode="Single" SelectionUnit="CellOrRowHeader"
ItemsSource="{Binding}"
Height="200" HorizontalAlignment="Left" Margin="28,43,0,0"
Name="gridPersons" VerticalAlignment="Top" Width="292" >
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Width="SizeToCells" MinWidth="150"
Binding="{Binding Name}"
IsReadOnly="True"/>
<DataGridCheckBoxColumn Header="Selected" Width="SizeToCells" MinWidth="100"
Binding="{Binding IsSelected}"
IsReadOnly="false"/>
</DataGrid.Columns>
</DataGrid>