Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Changing MainPage between AppShell and NagivationPage breaks app screen.

$
0
0

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 file.

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.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>