Navigation.PushAsync(new Page()) 不适用于 Xamarin.Forms 中的某些页面 [英] Navigation.PushAsync(new Page()) is not working for some pages in Xamarin.Forms

查看:43
本文介绍了Navigation.PushAsync(new Page()) 不适用于 Xamarin.Forms 中的某些页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Xamarin.Forms 并尝试使用导航来实现应用程序.我创建了一个 Xamarin.Forms 共享项目解决方案并添加了我的前两页.它们工作正常,导航也是如此.我添加了另一个页面并以与前两个相同的方式将它们链接起来,但它不起作用.我单击按钮导航到视图,但没有任何反应.

I am using Xamarin.Forms and trying to implement an app with Navigation. I Created a Xamarin.Forms shared project solution and added my first two pages. They work correctly and so does the navigation. I added another page and linked them up the same way as the first two and it does not work. I click the button to navigate to the view and nothing happens.

我把两个视图都这样连接起来

I wire up both of the views like such

btnPurchase.Clicked += (s, e) => this.Navigation.PushAsync(new PurchasePage());
btnContactUs.Clicked += (s, e) => this.Navigation.PushAsync(new ContactUsPage());

连接点击事件后,我将两个按钮添加为我的堆栈布局中的子项.

After wiring up the click event I add both buttons as children in my stacklayout.

两个按钮都显示在视图中.但是,btnContactUs 按钮是唯一一个被推送到导航堆栈上的按钮.

Both buttons show up in the view. However, the btnContactUs button is the only one that gets pushed onto the navigation stack.

有什么想法吗?

推荐答案

我想通了.

我更改了我的 SharedProject 的名称,其中从我的 iOS 和 Android 项目中删除了引用.令人惊讶的是,在我进行了清理/重建之前,我没有收到任何参考错误.再次连接共享项目后,导航正常工作.

I had changed the Name of my SharedProject in which it removed the reference from my iOS and Android project. Surprisingly I did not receive any reference errors until I did a clean / rebuild. Once I hooked up the shared project again, the navigation worked correctly.

这篇关于Navigation.PushAsync(new Page()) 不适用于 Xamarin.Forms 中的某些页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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