Question

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?

Was it helpful?

Solution

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>

OTHER TIPS

You can try to add a second data trigger to set the checkbox to false. As I can see from your code you set the IsChecked only to true, but never to false.

In stead of using Click to determine the changes, perhaps you can use the Checked and Unchecked events ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top