简体   繁体   English

使用Xamarin.Forms在Windows Phone上导航

[英]Navigation on Windows Phone with Xamarin.Forms

I am using Xamarin.Forms to write a cross platform app. 我正在使用Xamarin.Forms编写跨平台应用程序。

To change between Pages I am using Navigation.PushAsync(new Page()); 要在页面之间切换,我正在使用Navigation.PushAsync(new Page()); . This works fine when there is a NavigationPage . 当有NavigationPage时,此方法工作正常。

Now I want to get rid of the NavigationPage on Windows Phone 8.1, because it is destroying my layout. 现在,我想摆脱Windows Phone 8.1上的NavigationPage ,因为它破坏了我的布局。

The Xamarin.Forms guides note, that you do not need a NavigationPage on Windows Phone. Xamarin.Forms指南说明,Windows Phone上不需要NavigationPage

Also note that the Windows Phone platform provides navigation natively. 另请注意,Windows Phone平台本身提供导航。 Therefore, you do not need to use a NavigationPage object to get navigation on that platform. 因此,您无需使用NavigationPage对象来在该平台上进行导航。

Bu when I do not use a NavigationPage, an Exception will be thrown. 但是,当我不使用NavigationPage时,将引发异常。

在此处输入图片说明

So what can I do to use Navigation without NavigationPage on Windows Phone? 所以,我能做些什么,才能使用导览没有NavigationPage在Windows Phone?

You can use PushModalAsync if it is disturbing your layout. 如果它会干扰您的布局,则可以使用PushModalAsync。 I don't why such a statement in Xamarin site, because all navigations are handled by adding a navigation page. 我不为什么在Xamarin网站中这样声明,因为所有导航都是通过添加导航页面来处理的。

https://developer.xamarin.com/api/member/Xamarin.Forms.INavigation.PushModalAsync/p/Xamarin.Forms.Page/ https://developer.xamarin.com/api/member/Xamarin.Forms.INavigation.PushModalAsync/p/Xamarin.Forms.Page/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM