Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

CheckBox doesn't change visual state when updated from ViewModel

igorkr_10igorkr_10 Member ✭✭✭✭
edited March 2020 in Xamarin.Forms

Hi all.
I have a CheckBox binded to value IsInheritedMarkup in ViewModel. After the data loaded I want to read a new value from property. For this I call

this.OnPropertyChanged(nameof(IsInheritedMarkup));

But the CheckBox stays shown as checked always even if IsInheritedMarkup=false;

So, as I see the CheckBox cannot redraw itself when updated from ViewModel.
But! All works properly with Switch. When the value is false Switch is toggling to false (see screenshots).

<!--<Switch IsToggled="{Binding IsInheritedMarkup, Mode=TwoWay}" VerticalOptions="Center"/>-->
<CheckBox IsChecked="{Binding IsInheritedMarkup, Mode=TwoWay}" VerticalOptions="Center"/>

Is this a bug with CheckBox?

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    I tested it with a simple page but it worked as expected:

    I attached it here and could you share your repo so that I could test this issue with the same environment as yours.

  • igorkr_10igorkr_10 Member ✭✭✭✭

    Thanks for response.
    In sandbox CheckBox works as well. I need more time to investigate my project on this problem.

  • LandLuLandLu Member, Xamarin Team Xamurai

    Fell free to ask here if you could provide an issued sample.

  • abcr_1abcr_1 Member ✭✭

    Try assigning the itemssource again to the list after update.

Sign In or Register to comment.