How to navigate one Content page to another Content page from client project (IOS/Android) in xamarin forms?

后端 未结 1 759
轻奢々
轻奢々 2021-01-02 21:30

How to navigate one content page to another content page from client project in xamarin forms?

I have done implementing push notification in each platform in differe

相关标签:
1条回答
  • 2021-01-02 22:02

    "Main Page" has to be a navigation page in order to navigate with the push pop navigation. You have a couple of options.

    Option 1:

    Swap out MainPage with your new page and use content pages.

    App.Current.MainPage = your new content page
    

    Option 2: (Probably the better option)

    Make App.Current.MainPage a NavigationPage rather than a ContentPage then push your first content page to it. When you need to go to the second content page use the push navigation architecture.

    App.Current.MainPage = new NavigationPage;
    App.Current.MainPage.Navigation.PushAsync(Page1);
    App.Current.MainPage.Navigation.PushAsync(Page2);
    

    Docs: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/controls/pages/

    UPDATE

    Note that since this answer much better ways have come along for navigation such as docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/… app shell routing.

    Other choices are Prism MVVM or your own view model locator prismlibrary.com/docs/viewmodel-locator.html. The short coming in using this built in navigation is it lacks view model to view model navigation and depends on page to page which causes unwanted coupling of views and just plain clunky navigation.

    0 讨论(0)
提交回复
热议问题