如何从xamarin表单中的客户端项目(IOS/Android)将一个内容页面导航到另一个内容页面?

Pav*_*ekh 2 c# navigation xamarin xamarin.forms

如何从xamarin表单中的客户端项目将一个内容页面导航到另一个内容页面?

我已经以不同的方式在每个平台上实现了推送通知.我需要导航到当前内容页面中的其他内容.

我尝试在GCMService的OnMessage方法中使用下面的代码.我的问题是第二个导航内容页面的构造函数被调用并成功调试.但我的屏幕仍然显示当前页面不显示第二个导航内容页面.

App.Current.MainPage.Navigation.PushAsync (new SecondNavigationContentPage());
Run Code Online (Sandbox Code Playgroud)

Cli*_*ntL 9

"主页面"必须是导航页面才能使用推送弹出导航进行导航.你有几个选择.

选项1:

使用新页面交换MainPage并使用内容页面.

App.Current.MainPage = your new content page
Run Code Online (Sandbox Code Playgroud)

方案2 :(可能是更好的选择)

使App.Current.MainPage成为NavigationPage而不是ContentPage,然后将您的第一个内容页面推送到它.当您需要转到第二个内容页面时,请使用推送导航架构.

App.Current.MainPage = new NavigationPage;
App.Current.MainPage.Navigation.PushAsync(Page1);
App.Current.MainPage.Navigation.PushAsync(Page2);
Run Code Online (Sandbox Code Playgroud)

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