I have a WPF checkbox binded to ViewModel nullable boolean property. I am setting this property to false or true in Constructor, to avoid Interminent state but no matter what I do the Initial state of checkbox stays grayed. The binding working just fine since once I change the state by clicking the checkbox on UI I am getting controls values (true/false). Any Ideas?
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");
    }
}
                The reason for that is because it's initially null.
private bool? _mutualChb;
public bool? MutualChb
{
    get { return (_mutualChb != null ) ? _mutualChb : false; }
    set
    { 
        _mutualChb = value;               
        OnPropertyChanged("MutualChb"); 
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With