Searched a lot about this problem but never found a answer, that solved it.
I´ve got the following CheckboxColumn in a WPF datagrid:
<DataGridCheckBoxColumn Header="Erledigt" Binding="{Binding Path=erledigt}" />
The variable erledigt contains 0 or 1. Now I want, that if the Checkbox is checked, the cellbackground is green.
Hopelessly searched for a checked property. How can I manage this?
You could add a
CellStyleto the column in which you just use aDataTriggeronerledigt, you don’t need theIsCheckedproperty itself. Using theElementStyleandEditingElementStyleyou should be able to add a normalTriggeronIsCheckedas the style should be one applied theCheckBoxes, however the scope would also be limited to theCheckBoxesthemselves and not the cell.You can also bind to the
CheckBox.IsCheckedfrom the cell level, this has the effect that the colour will be changing right away instead of after committing the change which then affects the bound property. To do so change the trigger in theCellStyleto this: