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 new Xamarin.Forms 4.0 solution with AppShell Template at Visual Studio 2019.
2) Add a Content Page into Views folder (LoginPage.xaml)
3) Change MainPage at App.xaml.cs like this;
public App()
{
InitializeComponent();
DependencyService.Register<MockDataStore>();
//MainPage = new AppShell();
MainPage = new NavigationPage(new Views.LoginPage());
}
4) Change MainPage in LoginPage like this (I added a Button at LoginPage.xaml);
private void LoginButton_Clicked(object sender, EventArgs e)
{
Application.Current.MainPage = new AppShell();
}
5) Add a MenuItem at AppShell and Add MenuItem Click event handler 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.
https://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 common pattern to implement Login function and I am regarding it may be a XF bug.
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.