My Question:
In Xamarin.Forms 4.2+, can I suspend the App Shell in any way while I am manipulating it? Or can I suspend the whole UI layouting and rending for an instance?
My Situation:
I am creating an App with Xamarin.Forms where I use the new Shell Navigation. Cause I change the Flyout Menu during app runtime, I want to add and remove some of the FlyoutItem by code.
As an example, I have a LoginPage which I want to replace by a UserProfilePage in the App Menu (Flyout Menu). I always have an AppInfoPage in the menu.
Whenever I remove a FlyoutItem, Shell wants to display the next item. So when I remove the LoginPage, Shell displays AppInfoPage or at least calls the constructor and executes the overload of OnAppearing on the AppInfoPage. OnAppearing then does a lot of things to prepare the App info, which is not needed now cause the page will be OnDisappearing just a few ticks later.
Most UI frameworks have some function like this to avoid unneeded UI layouting and rendering. I tried setting IsVisible = false, IsBusy = true and calling BatchBegin(), but none of them helped me.
Answers
You could define two different shell in App , and switch
App.MainPage
at the right time , then the heavy works would be only executed once .Thank you for sharing your idea. I very appreciate that. I think it is a good idea and I tried it in a small example. Switching the Shell works. But I am facing two issues:
I am using the latest stable Xamarin.Forms build from nuget: 4.2.0.848062
I dit no try in iOS.
A short summary of my code:
AppShellLogin.xaml:
AppShell.xaml:
In App.xaml.cs I change the current Shell according to the users state in the App. This is triggered by an Observable over System.Reactive. :
The crash I described in my previous post is possibly related with an issue already reported by another user to the Xamarin bugtracker:
https://github.com/xamarin/Xamarin.Forms/issues/7864
The crash from my previous post: