0

I have this CheckBox:

<CheckBox x:Name="checkNotAppointed" Grid.Column="1" Grid.Row="2" Content="Not Appointed" >
    <CheckBox.Style>
        <Style TargetType="{x:Type CheckBox}">
            <Setter Property="Margin" Value="2" />
            <Setter Property="IsEnabled" Value="True" />
            <Setter Property="IsChecked" Value="{Binding FilterForNotAppointed, UpdateSourceTrigger=PropertyChanged}" />
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsChecked, ElementName=checkElder}" Value="True" />
                        <Condition Binding="{Binding IsChecked, ElementName=checkMinisterialServant}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsEnabled" Value="True" />
                </MultiDataTrigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsChecked, ElementName=checkElder}" Value="False" />
                        <Condition Binding="{Binding IsChecked, ElementName=checkMinisterialServant}" Value="True" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsEnabled" Value="True" />
                </MultiDataTrigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsChecked, ElementName=checkElder}" Value="False" />
                        <Condition Binding="{Binding IsChecked, ElementName=checkMinisterialServant}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsChecked" Value="True" />
                    <Setter Property="IsEnabled" Value="False" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </CheckBox.Style>
</CheckBox>

If I untick either checkElder or checkMinisterialServant it has no affect on checkNotAppointed. Correct.

If I then untick both of them, it checks the checkNotAppointed and disables. Correct.

If I then check one of the other two, it enables checkNotAppointed but always unchecks it. Why?

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • Maybe the answer is on FilterForNotAppointed. On your third scenario, what is the value of FilterForNotAppointed's IsChecked? – tgpdyk Jun 29 '16 at 02:59
  • @tgpdyk It was ticked before so it should be true. But I don't know who to debug the XAML side of things. Where would the breakpoint go? – Andrew Truckle Jun 29 '16 at 04:42

1 Answers1

0

There is a missing part (IsChecked) on your Setter's Binding, it should be:

  <Setter Property="IsChecked" Value="{Binding IsChecked, ElementName=FilterForNotAppointed}"/>

Based on your comment, the FilterForNotAppointed is another combo box, so you can check it by adding these:

<StackPanel Orientation="Horizontal">
        <Label Content="FilterForNotAppointed' IsChecked:"/>
        <TextBlock VerticalAlignment="Center" Text="{Binding IsChecked, ElementName=FilterForNotAppointed}"/>
 </StackPanel>

 <StackPanel Orientation="Horizontal">
        <Label Content="checkNotAppointed's IsChecked:"/>
        <TextBlock VerticalAlignment="Center" Text="{Binding IsChecked, ElementName=checkNotAppointed}"/>
 </StackPanel>
tgpdyk
  • 1,203
  • 9
  • 13