【问题标题】:unable to convert from 'page' to 'Xamarin.Forms.Page'无法从“页面”转换为“Xamarin.Forms.Page”
【发布时间】:2020-03-12 10:23:01
【问题描述】:

我想导航到 Xamarin Forms 中的其他页面,但它不起作用。 我的代码是:

private async void btnlogin_Clicked(object sender, EventArgs e)
        { await Navigation.PushAsync(new CreateExpense());}

错误是:

无法从“页面”转换为“Xamarin.Forms.Page”。顺便说一句 “页面”在 contentView 中。

【问题讨论】:

  • 无法导航ContentView,页面必须是Content Page

标签: c# xaml xamarin xamarin.forms navigation


【解决方案1】:

你不能导航到内容视图所以CreateExpense应该使用Xamarin.Forms并且应该继承ContentPage,所以你应该在CreateExpense上做一些类似下面的事情

using Xamarin.Forms;

class CreateExpense : ContentPage

【讨论】:

    【解决方案2】:

    它不起作用的原因是您只能将继承自 Xamarin.Forms.Page 类的任何类推入导航堆栈,例如 ContentPage

    另一方面,ContentView 是 Xamarin.Forms.View 而不是 Page 来完成这项工作你可以做两件事

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-11
      • 2017-08-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-11
      • 2012-05-17
      • 1970-01-01
      相关资源
      最近更新 更多