PushModelAsync and Shell GoToAsync is not working in .NET MAUI android while we are navigating to Tabbed page from content page

Mandeep Kaur 1 Reputation point
2023-01-10T11:48:47.277+00:00

PushModelAsync and Shell GoToAsync is not working in .NET MAUI android while we are navigating to Tabbed page. Please have below points to reproduce the same. Project type = .NET MAUI Target .NET Runtime = net6.0 also tested on .net7.0 as well Microsoft MAUI Dependency = 6.0.547 Issue - While we are navigating to TabbedPage from content page its showing error Object reference not set as instance of object Steps to reproduce:-

  1. Create .NET MAUI project with AppShell and main Page.
  2. Add Tabbed page and register it on App Shell RegisterRoute(Routing.RegisterRoute("TabbedPage1", typeof(TabbedPage1));)
  3. Create button on Main page and its click event to navigate to
tabbed page= private async void GoToTabbedPageButtonClicked(object sender, EventArgs e)
    {
        await Shell.Current.GoToAsync("TabbedPage1");
    }
  1. While tapping on button its giving error object reference not set instance of object
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,838 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 78,671 Reputation points Microsoft Vendor
    2023-01-11T05:21:05.0966667+00:00

    Hello,

    I can reproduce this issue in MAUI.

    I use same code. it is works in the Xamarin.

    This issue is reported in MAUI GitHub page, please waiting for PG's update in these threads.

    Make Shell compatible with the other page types in .NET MAUI

    Android Pushing TabbedPage from Shell-based ContentPage causes NRE. #7615

    Here is a workaround, you can use Navigation.PushModalAsync to navigate shell to tabbedpage.

    await Navigation.PushModalAsync(new TabbedPage1());
    

    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.


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.