maui
maui copied to clipboard
After updating Application.Current.MainPage, navigation to other pages doesn't work
Description
Run non-shell app which starts off with a login page. Enter credentials on login page and click button to login, which then sets Application.Current.MainPage = the real main page. Then on the main page, click a button to navigate to a second page (from which you should be able to go back to the main page). The Navigation.PushAsync method doesn't do anything and the second page never appears.
Steps to Reproduce
Run the repro app. Click on the button on the login page to 'login', which will show the main page. Then click on the 'Show the second page' button. Instead of showing the second page, nothing happens.
Link to public reproduction project repository
https://github.com/smitha-cgi/NavigationTest.git
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 13
Did you find any workaround?
No response
Relevant log output
No response
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Workaround for this - treat the initial page as a Navigation Page, and then navigate to the 'main' page and remove the login page from the list of pages using the RemovePage method. So example app code will look like this:
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new LoginPage());
}
and LoginPage code looks like this:
private async void ButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new MainPage());
Navigation.RemovePage(this);
}
Verified this issue with Visual Studio 17.7.0 Preview 1.0. Can repro on android platform with sample project.
NavigationTest-master.zip
Having the same issue still on .net 8 android, Device - Android 14
Also, having the same issue still on .net 8 android, Device - Android 13