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 different way. I need to navigate to another content from current content page.
i try to use below code in GCMService's OnMessage method. My Problem is Second navigation content page's constructor are called and debug successfully. but my screen still display current page not to display second navigation content page.
App.Current.MainPage.Navigation.PushAsync (new SecondNavigationContentPage());
A flyout page typically displays a list of items, as shown in the following screenshots: The location of the list of items is identical on each platform, and selecting one of the items will navigate to the corresponding detail page.
"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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With