Xamarin.forms Xamarin形式。获取winPhone';s应用程序道具';PCL中的s

Xamarin.forms Xamarin形式。获取winPhone';s应用程序道具';PCL中的s,xamarin.forms,Xamarin.forms,我正试图从我的xamarin froms项目中的WinPhone解决方案中获取道具,以便在我的PCL中使用它们 因此,在我的应用程序/PCL中,可以执行以下操作 App.WinPhone.Prop=2; 或 Var temp=App.WinPhone.Prop 感谢您的时间也许James Montemagno会帮助您。您需要在您的WP原生项目中创建一个新类。e、 g [assembly: Dependency (typeof(MyProperties))] namespace MyNamespa

我正试图从我的xamarin froms项目中的WinPhone解决方案中获取道具,以便在我的PCL中使用它们

因此,在我的应用程序/PCL中,可以执行以下操作

App.WinPhone.Prop=2; 或 Var temp=App.WinPhone.Prop


感谢您的时间

也许James Montemagno会帮助您。

您需要在您的WP原生项目中创建一个新类。e、 g

[assembly: Dependency (typeof(MyProperties))]
namespace MyNamespace
{
    public class MyProperties: IMyProperties
    {

         public string TheProperty { get { return "something"; } }

    }
}
在PCL中创建适当的接口

那么在你的PCL里呢

 DependencyService.Get<IMyProperties>().TheProperty
DependencyService.Get()。属性
此网页包含更多信息: