Xamarin形式获得

问题描述:

我试图用这个方法系统API不是某些地区: https://developer.xamarin.com/api/member/System.Type.GetInterfaces()/ 这样的:Xamarin形式获得

public MainPage(Type type) { 
    if (type.GetInterfaces().contains("Form")) { 
     // go on 

但我Xamarin Studio不承认GetInterfaces方法,为什么呢?

听起来像你正在使用PCL Xamarin Forms项目。我建议你阅读关于here的更多信息或观看互联网上的一些有用的视频(如this之一,它讨论不同的PCL配置文件),但基本上PCL项目试图允许在所有平台上提供许多通用API。这意味着如果某个平台不支持GetInterfaces()或者如果Forms团队尚未实现该API,它将不会从Forms项目中获得。

Xamarin Forms的好处在于,如果需要,您仍然可以访问所有本机API。为此,您需要创建一个接口并使用Xamarin Forms Dependency Service(link),该服务可能允许您从Forms项目访问该API。

如果你需要一个如何做到这一点的例子,请让我知道。