C#C
C#13mo ago
nathanAjacobs

WPF - DataGridCheckBoxColumn Issues

In WPF, how can I have a DataGridCheckBoxColumn that allows me to click the checkboxes without having to select the row first. It's weird that when I click the checkbox it selects the row rather than just clicking the checkbox

I have this which seems to work, but it doesn't seem to update the value in the model when the checkbox is clicked. It only gets updated when I click the cell and click away.
How can I fix it so that when I click the checkbox it updates the model?

<DataGridTemplateColumn Header="Enabled" MinWidth="100" Width="100">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <CheckBox IsChecked="{Binding Enabled, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Was this page helpful?