我有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>
如果我取消checkElder
或checkMinisterialServant
,则不会影响checkNotAppointed
。正确的。
如果我然后取消它们两者,它会检查checkNotAppointed
并禁用。正确的。
如果我再检查其他两个中的一个,它会启用checkNotAppointed
,但始终取消选中它。为什么呢?
答案 0 :(得分:0)
Setter的Binding上有一个缺失的部分(IsChecked),它应该是:
<Setter Property="IsChecked" Value="{Binding IsChecked, ElementName=FilterForNotAppointed}"/>
根据您的评论,FilterForNotAppointed是另一个组合框,因此您可以通过添加以下内容来检查它:
<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>