主页面的SetContentView

时间:2015-08-20 09:10:33

标签: c# android xamarin xamarin.forms

Xamarin.Android 我可以写:

SetContentView(Resource.Layout.Main);

用于设置Main.axml的活动内容

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

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

def generate_confirmation_code unless self[:confirmed] if(self[:type] == 'Patient') self.confirmation_code = SecureRandom.urlsafe_base64(20) self.confirmed = false else self.confirmed = true end end end 与平台无关。您尝试在其上调用Android特定方法Xamarin.Forms.Page。那不行。如果要设置布局,可以使用XAML或在代码中设置SetContentView()的{​​{1}}。 您不能在Xamairn.Forms中使用AXML布局。

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