Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DanielCauser opened this issue Oct 10, 2024 · 2 comments
Open

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

DanielCauser opened this issue Oct 10, 2024 · 2 comments
Labels
area-navigation NavigationPage migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@DanielCauser
Copy link

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

@DanielCauser DanielCauser added the t/bug Something isn't working label Oct 10, 2024
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels Oct 11, 2024
@ninachen03
Copy link

This issue has been verified using Visual Studio 17.12.0 Preview 2.1(8.0.91 & 8.0.21). Can repro this issue at Android platform.

@jsuarezruiz jsuarezruiz added this to the Backlog milestone Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-navigation NavigationPage migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants