mauibinding-context

.NET Maui BindingContext losed (not working)


I have a few issues. I created an application on Xamarin and I started converting it into Maui. But I have some issues. In Xamarin I deliberately choosed to declared in the App.cs the partial class used for bindingcontext (SidebarVM) for example. By doing so, when I can easily access from other pages or other viewmodels a value inside the "SidebarVM" partial class by simply requesting it => bool myboolean = App.SidebarVM.MyValueRequested;

I use CommunityToolkit.Mvvm in the partial class used for the BindingContext.

In the contentpage.cs, I declared the bindingcontext as follow BindingContext = App.SidebarVM;

In the contentpage.xaml, I declared the bindingcontext by using x:DataType=sb:SidebarVM

Everything worked perfectly in xamarin.forms, however in .net MAUI I have the following issues come accross:

  1. The bindingcontext lose track of value OnPropertyChanged even if the value is changed
  2. The User interface never update due to the 1st issue.

Do any expert on the subject have a solution a guidance to the described issue?


Solution

  • It is triggering but the actual solution to this issue is to always create your Maui pages inside <VerticalStackLayout>...</VerticalStackLayout> otherwise, this issue happens.

    Also, AbsoluteLayout have a big issue in .net maui. The use is really practical if you want to display something on top of the page, but this bug is critical for UI experience.