maui icon indicating copy to clipboard operation
maui copied to clipboard

After updating Application.Current.MainPage, navigation to other pages doesn't work

Open smitha-cgi opened this issue 2 years ago • 1 comments

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

smitha-cgi avatar Nov 14 '22 03:11 smitha-cgi

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.

ghost avatar Nov 14 '22 15:11 ghost

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);        
}

smitha-cgi avatar Dec 19 '22 03:12 smitha-cgi

Verified this issue with Visual Studio 17.7.0 Preview 1.0. Can repro on android platform with sample project. NavigationTest-master.zip 11330

Zhanglirong-Winnie avatar May 31 '23 07:05 Zhanglirong-Winnie

Having the same issue still on .net 8 android, Device - Android 14

Khadeeja-Madathil avatar Apr 25 '24 08:04 Khadeeja-Madathil

Also, having the same issue still on .net 8 android, Device - Android 13

Richard-Starrtec avatar Apr 30 '24 03:04 Richard-Starrtec