Hello.
I found an issue of Xamarin.Forms 4.0 on Changing MainPage between AppShell and NagivationPage.
It is very easy to reproduce the issue.
1) Create a Xamarin.Forms 4.0 solution with AppShell Template
2) Add a Content Page (LoginPage.xaml)
3) Change MainPage at App.xaml.cs like this;
public App()
{
InitializeComponent();
DependencyService.Register<MockDataStore>();
//MainPage = new AppShell();
MainPage = new NavigationPage(new LoginPage());
}
4) Change MainPage in LoginPage like this;
private void LoginButton_Clicked(object sender, EventArgs e)
{
Application.Current.MainPage = new AppShell();
}
5) Add a MenuItem in AppShell and Add Logout method like this;
private void LogoutMenuItem_Clicked(object sender, EventArgs e) {
Application.Current.MainPage = new NavigationPage(new Views.LoginPage());
}
6) Bulid and run the app
7) “Login and Logout” action makes app screen broken like the attached screen shot.
www.dropbox.com/s/skbgti26v6m2x3u/Screenshot_20190627-181115.png?dl=0
App MainPage is changed like this;
NavigationPage(new Views.LoginPage()) => new AppShell() => NavigationPage(new Views.LoginPage()).
It is very common pattern to implement Login function and I am regarding it must be a XF bug.
It is very easy to reproduce, but I attached my source code for the convenience.
My testing environment is Visual Studio 2019 on Windows 10 Pro and I updated XF 4.0 up to date.
Is there any solution or workaround to solve the issue?
Best regards.