WPF 将复选框绑定到 bool?

WPF Bind checkbox to bool?

我有一个 WPF 复选框绑定到 ViewModel 可为 null 的布尔值 属性。我在构造函数中将此 属性 设置为 false 或 true,以避免 Interminent 状态,但无论我做什么,复选框的初始状态都保持灰色。绑定工作正常,因为一旦我通过单击 UI 上的复选框更改状态,我就会获得控件值 (true/false)。有什么想法吗?

XAML:

<CheckBox Margin="0,4,0,3"
          VerticalAlignment="Center"
          Content="Mutual"
          IsChecked="{Binding MutualChb}" />

ViewModel:

public ContstrutorViewModel()
{
    MutualChb = true;
}

private bool? _mutualChb;
public bool? MutualChb
{
    get { return _mutualChb; }
    set
    { 
        _mutualChb = value; 
        _mutualChb = ( _mutualChb != null ) ? value : false;
        OnPropertyChanged("MutualChb");
    }
}

这是因为它最初为空。

private bool? _mutualChb;
public bool? MutualChb
{
    get { return (_mutualChb != null ) ? _mutualChb : false; }
    set
    { 
        _mutualChb = value;               
        OnPropertyChanged("MutualChb"); 
    }
}