主页面的SetContentView

SetContentView for main page

Xamarin.Android中我可以写:

SetContentView(Resource.Layout.Main);

用于设置来自 Main.axml

的 activity 内容

如何为 Xamarin.Forms 做同样的事情?如何从主页上的 Main.axml 移动数据?

Page page = App.GetMainPage();
page.SetContentView(Resource.Layout.Main); // page doesn't contain method SetContentView

A Xamarin.Forms.Page 与平台无关。您尝试在其上调用 Android 特定方法 SetContentView()。那是行不通的。当您想设置布局时,您可以使用 XAML 或在代码中设置 ContentPageContent。 您不能在 Xamairn.Forms.

中使用 AXML 布局

看这里:http://developer.xamarin.com/guides/cross-platform/xamarin-forms/getting-started/ and here http://developer.xamarin.com/guides/cross-platform/xamarin-forms/controls/pages/

您应该查看自定义渲染器。这就是我们可以在 Xamarin.Forms 中包含平台特定视图的方式。您将需要实施 PageRenderer 以实施 Activity 布局。