How do I navigate to a new page from a Popup message?

Brenda 60 Reputation points
2023-06-20T17:11:53.47+00:00

I am trying to navigate to other pages from a popup message. Is it possible to do it?

I used Mopups and so far i can manage to navigate to the page but when I click the back button from the content page (actual page), the app crash. I guess it is because Mopups only allow to do it with popup and not navigation stack.

Is it possible to do it with Community toolkit .Net MAUI as it is with Xamarin?

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

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,131 Reputation points Microsoft External Staff
    2023-06-21T03:09:27.5766667+00:00

    Hello,

    I am trying to navigate to other pages from a popup message. Is it possible to do it?

    After testing, this functionality could be achieved using the MAUI CommunityToolkit's Popup control.

    You could refer to the following steps.

    Step 1. Create pop-ups based on Popup's documentation: Popup.

    Step 2. Register the route according to the documentation of MAUI navigation: Register detail page routes.

    Routing.RegisterRoute("Page1", typeof(NewPage1));
    

    Step 3. Add a button to the Popup page and implement the page jump function.

    <Button Text="Navi_Test" Clicked="Button_Clicked"/>
    
    private void Button_Clicked(object sender, EventArgs e)
    {
        this.Close();
        AppShell.Current.GoToAsync("Page1");
    }
    

    It has been tested that using this method does not cause the program to crash when the back button is clicked.

    Best Regards,

    Alec Liu.


    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.