如何以Xamarin形式从客户端项目(IOS/Android)将一个“内容"页面导航到另一“内容"页面? [英] How to navigate one Content page to another Content page from client project (IOS/Android) in xamarin forms?

查看:65
本文介绍了如何以Xamarin形式从客户端项目(IOS/Android)将一个“内容"页面导航到另一“内容"页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以Xamarin形式从客户端项目将一个内容页面导航到另一内容页面?

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.

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

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());

推荐答案

主页面"必须是导航页面,才能使用弹出式导航进行导航.您有两种选择.

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

选项1:

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

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

App.Current.MainPage = your new content page

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

Option 2: (Probably the better option)

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

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);

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

这篇关于如何以Xamarin形式从客户端项目(IOS/Android)将一个“内容"页面导航到另一“内容"页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆