我目前正在使用Windows Phone 8.1 [RT]应用程序,我正在使用GeoLocation进行地图服务,我想要在设备位置打开/关闭时发生的事件,与用于互联网连接的NetworkStatusChangedEventHandler
相同。
我为此创建了以下代码
public static bool IsLocationOn
{
get
{
Geolocator locator = new Geolocator();
if (locator.LocationStatus == PositionStatus.Disabled)
{
return false;
}
else
{
return true;
}
}
}
但是我希望在整个应用程序中触发事件 谢谢
答案 0 :(得分:0)
Geolocator有一个StatusChanged
事件。从那里开始,只需订阅它。
locator.StatusChanged += Geolocator_StatusChanged;
private void Geolocator_StatusChanged(Geolocator locator, StatusChangedEventArgs e)
{
// Whatever
}