mardi 2 octobre 2018

IsChecked Checkbox binding not responding accordly

I have a checkbox on MenuItem like this

<MenuItem Header="FullScreen" 
          Click="FullScreen"
          IsChecked="{Binding IsFullScreen}">
</MenuItem>

I just want to set the checkbox with true or false on my MenuItem BUT when my bool changes, I see the getter being called but checkbox state doesn't change.

private bool? isFullScreen;
public bool? IsFullScreen
{
    get { return isFullScreen ?? false; }
    set
    {
        if (isFullScreen == value)
            return;

        isFullScreen = value;
        OnPropertyChanged();
    }
}

I've other part of XAML binding to IsFullScreen (not a checkbox) and works fine

<DataTrigger Binding="{Binding IsFullScreen}" Value="True">
    <Setter Property="Visibility" Value="Collapsed" TargetName="MainDock"/>
    <Setter Property="BorderThickness" Value="0 0 0 0"/>
</DataTrigger>

I saw a lot of solutions here but none helped me

What is the right way? Why my IsChecked don't work as should?




Aucun commentaire:

Enregistrer un commentaire