WPF: Problem with Checkbox when binding datatrigger to property “Ischecked”

checkboxdatatriggerpropertieswpf

I have a checkbox in GridViewColumn which i use for show/change database value. The click event for the checkbox is used for change value in the database. For handling the state of property "IsChecked" I'm using datatrigger and a setter, se xaml code below:

<Style TargetType="CheckBox">
    <Setter Property="IsEnabled" Value="True" />
    <Style.Triggers>
        <DataTrigger Binding="{Binding Path=ID, Converter={StaticResource Converter}}"   Value="true">
            <Setter Property="IsChecked" Value="True"/>
        </DataTrigger>
    </Style.Triggers>
</Style>

The binding works great until I click the checkbox. After I clicked the checkbox for the first time the state of the property "IsChecked" don't updates if a manually in the Database change the value which i mapped to the property "IsChecked".
If I map for example the same value to the property "Content" of the checkbox the trigger works fine even after I've clicked the checkbox.

Does anyone no whats the problem is?

Best Answer

Shouldn't

<Style TargetType="CheckBox">

instead be:

 <Style TargetType="{x:Type CheckBox}">

Edit:

you could try this:

    <Style TargetType="{x:Type CheckBox}" >
        <Setter Property="IsChecked" Value="{Binding Path=ID, Converter={StaticResource Converter}}" />
    </Style>
Related Topic