Xamarin 形式。在 PCL 中获取 winPhone 的 App Prop
Xamarin forms. get winPhone's App Prop's in PCL
我正在尝试从我的 xamarin froms 项目中的 WinPhone 解决方案中获取道具,以便我可以在我的 PCL.
中使用它们
所以在我的 App/PCL 中可以做类似
的事情
App.WinPhone.Prop = 2;
要么
可变温度 = App.WinPhone.Prop
感谢您的宝贵时间
也许来自 James Montemagno 的 this plugin 会帮助你。
您需要在您的 WP Native 项目中创建一个新的 class。例如
[assembly: Dependency (typeof(MyProperties))]
namespace MyNamespace
{
public class MyProperties: IMyProperties
{
public string TheProperty { get { return "something"; } }
}
}
在您的 PCL 中创建适当的界面。
然后在你的PCL中做
DependencyService.Get<IMyProperties>().TheProperty
此网页有更多信息:https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/
我正在尝试从我的 xamarin froms 项目中的 WinPhone 解决方案中获取道具,以便我可以在我的 PCL.
中使用它们所以在我的 App/PCL 中可以做类似
的事情App.WinPhone.Prop = 2; 要么 可变温度 = App.WinPhone.Prop
感谢您的宝贵时间
也许来自 James Montemagno 的 this plugin 会帮助你。
您需要在您的 WP Native 项目中创建一个新的 class。例如
[assembly: Dependency (typeof(MyProperties))]
namespace MyNamespace
{
public class MyProperties: IMyProperties
{
public string TheProperty { get { return "something"; } }
}
}
在您的 PCL 中创建适当的界面。
然后在你的PCL中做
DependencyService.Get<IMyProperties>().TheProperty
此网页有更多信息:https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/