Navigation help with .Net Maui app

Phunction 301 Reputation points
2024-06-27T20:48:22.0333333+00:00

I am trying to figure out a way to navigate. Right now I have the main page as a shell page with some content, from here I launch Tabbed Page sections, there are several and each page contains 5-6 tab pages.

This does not work in Android as you can't launch a tabbedpage from a shell page. (Works fine in Windows)

How do I replicate this so it works with Android? I need a main content page, and from there I need to launch other tabbedpages that contain their own tabs.

I could use PushModalAsync() but I would like to keep the built-in back button and modal does not allow for that.

Can I set the main page as a tabbed page but have no tabs, just a content page? And then can I launch other tabbed pages from a tabbed page?

Developer technologies | .NET | .NET MAUI
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2024-06-28T05:29:55.32+00:00

    Hello,

    TabbedPage is incompatible with .NET MAUI Shell apps, and an exception will be thrown if you attempt to use TabbedPage in a Shell app.

    From TabbedPage document

    Can I set the main page as a tabbed page but have no tabs, just a content page? And then can I launch other tabbed pages from a tabbed page?

    Yes, you can set the MainPage to MainPage =new NavigationPage( new NewTabbedPage1()); in the app.xaml.cs. As note: NewTabbedPage1 is a Tabbedpage.

    public partial class App : Application
    {
         public App()
         {
             InitializeComponent();
     
             MainPage =new NavigationPage( new NewTabbedPage1());
         }
    }
    

    Then when you need to navigate to second Tabbedpage, you can use Navigation.PushAsync to do it, and it will keep the back icon.

      await Navigation.PushAsync(new MyTabbedpagePage());
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.