这个问题一般出如今Triggers中Property指定的类型为Nullable。
解决的方法就是用DataTrigger取代Trigger, 然后用Binding+Converter转换为详细非Null值。
比方:
<Style x:Key="DisableStyle" TargetType="Button">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=ckb1, Path=IsChecked, Converter={StaticResource NullableToBooleanConverter}}" Value="true"></Condition>
<Condition Binding="{Binding ElementName=ckb2, Path=IsChecked, Converter={StaticResource NullableToBooleanConverter}}" Value="true"></Condition>
</MultiDataTrigger.Conditions>
<Setter Property="IsEnabled" Value="False"></Setter>
</MultiDataTrigger>
</Style.Triggers>
</Style>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=ckb1, Path=IsChecked, Converter={StaticResource NullableToBooleanConverter}}" Value="true"></Condition>
<Condition Binding="{Binding ElementName=ckb2, Path=IsChecked, Converter={StaticResource NullableToBooleanConverter}}" Value="true"></Condition>
</MultiDataTrigger.Conditions>
<Setter Property="IsEnabled" Value="False"></Setter>
</MultiDataTrigger>
</Style.Triggers>
</Style>
NullableToBooleanConverter:
public object Convert( object value , Type targetType, object parameter, CultureInfo culture )
{
Nullable<bool > isCheck = value as Nullable< bool>;
if (null == isCheck)
{
return false ;
}
else
{
return isCheck .Value;
}
}