Skip to content

Issue with NavigationPage Root Navigation in .NET MAUI - ANDROID #25187

@DanielCauser

Description

@DanielCauser

Description

Hi Team,

In Xamarin Forms, I used a NavigationPage as my App.MainPage, and handled navigation via NavigationPage.Navigation. This approach worked well with the tools available in Xamarin Forms, particularly for navigation flows where the root page of the app changes—such as switching from a LoginPage (a full-screen page) to a FlyoutPage or even a TabbedPage as the new root page.

As we know, the NavigationPage in Xamarin Forms did not allow direct changes to the root page. To work around this, I used the following pattern:

NavigationPage.Navigation.InsertPageBefore(new FlyoutPage(), NavigationPage.Navigation.NavigationStack[0]);
NavigationPage.Navigation.PopToRootAsync(false);

This approach involves inserting the new root page (FlyoutPage) before the current root page in the navigation stack and then popping to root. This pattern worked effectively and is also used by libraries like Sextant from ReactiveMarbles.

Steps to Reproduce

  1. Create a brand new app
  2. On App.cs set the MainPage = new NavigationPage(new ContentPage());
  3. On your ContentPage, create a button that navigates you to a FlyoutPage
  4. The code that navigates to the Flyout should be like this

Expected Outcome

The expected outcome is that the Page on Android should look like this:
Image

The Actual outcome

The FlyoutPage is not identified as Flyout, there is no Hamburguer button.
Image

Link to public reproduction project repository

https://github.com/DanielCauser/SextantNavigation/tree/daca/maui_pure_as_sextant/SextantNavigation

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 13 and Above

Did you find any workaround?

There is known workaround that would still allow us to user NavigationPage as the main navigation source for the app.

The only way to make it work is to Change the App.MainPage, which breaks all the principles applied in enterprise projects.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-navigationNavigationPagehas-workaroundmigration-compatibilityXamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convertpartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions