无法从 Xamarin 表单页面转换

Sam*_*Sam 4 c# cross-platform visual-studio xamarin xamarin.forms

我正在尝试在主页上加载带有单击事件的类,但它给了我以下错误:

参数 1:无法从“LocalDataAccess.recipe1”转换为“Xamarin.Forms.Page”

这是我的代码:

private async void recipe_Clicked(object sender, EventArgs e) {
    await Navigation.PushAsync(new recipe1());
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

小智 6

recipe1应该使用Xamarin.Formsand Inheritfrom ContentPage,所以你应该在 上执行以下操作recipe1

\n\n

using Xamarin.Forms;

\n\n

class Recipe1:ContentPage\xe2\x80\x93 迈克·达尔维什 "

\n\n

这工作很好!

\n

  • 另外,您应该将“<ContentView/>”从“.xaml”更改为“<ContentPage/>” (3认同)