【问题标题】:Do normal navigation in a Modal page seems to be not supported [Xamarin.Forms]似乎不支持在模态页面中进行正常导航 [Xamarin.Forms]
【发布时间】:2020-01-03 21:40:33
【问题描述】:

我尝试在模态页面中使用普通导航,但是当我进行导航时会显示错误:

PushAsync is not supported on Android, please use NavigationPage

我在我的模态页面中使用NavigationPage() 以允许我以正常方式导航, 有可能吗?

代码:

导航到模态页面的代码:

await Application.Current.MainPage.Navigation.PushModalAsync(
                    new NavigationPage(new MyModalPage());

(在模态页面中) 使用普通导航从模态页面导航到 MySecondPage 的代码:

await Application.Current.MainPage.Navigation.PushModalAsync(
                    new NavigationPage(new MySecondPage()));

然后弹出提到的错误

【问题讨论】:

  • 如果您希望我们帮助您,您需要发布相关代码
  • @Jason 我不想让任何人为我解决代码,我只想解释一下是否允许 Xamarin 表单做我想做的事情
  • 是的,您可以在模式中进行导航。但是你得到的错误让我认为你的代码有问题。
  • @Jason 我已经编辑了我的帖子,你可以参考一下吗?

标签: android xamarin xamarin.forms xamarin.android navigation


【解决方案1】:

在你的模态页面中,不要这样做

await Application.Current.MainPage.Navigation.PushModalAsync(
                new NavigationPage(new MySecondPage()));

改为这样做

await Navigation.PushAsync(new MySecondPage());

【讨论】:

    猜你喜欢
    • 2017-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-24
    • 1970-01-01
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    相关资源
    最近更新 更多