【发布时间】:2015-07-15 15:51:27
【问题描述】:
使用 Xamarin 共享项目。
我尝试在我的共享项目中包含 Xlabs 示例中的地理定位功能,但在调用 dependencyService 时遇到了问题。
我有一个内容页面,其中我的按钮有这样的命令:Command = new Command(async () => await GetPosition(), () => Geolocator != null)
命令导致:
private IGeolocator Geolocator
{
get
{
if (_geolocator == null)
{
_geolocator = DependencyService.Get<IGeolocator>();
_geolocator.PositionError += OnListeningError;
_geolocator.PositionChanged += OnPositionChanged;
}
return _geolocator;
}
}
当它应该调用_geolocator = DependencyService.Get<IGeolocator>(); 时什么也没有发生,_geolocator 保持为空。
我有来自 Xlabs 的所有引用,接口 IGeolocator 在我的项目中,为什么不调用 DependencyService??
【问题讨论】:
标签: c# android xamarin xamarin.forms xlabs