我正在尝试为我在ModelLib.cs中定义的方法实现一个回调,它有以下代码。但是e.UserSTate不可用。我们可以用某种方法替换它。
public class TrackingDetailsModel
{
public void GetCurrentLocation()
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(this.watcher_PositionChanged);
}
}
private void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Action<LocationInfo> target = (Action<LocationInfo>)e.UserState;//user state here is not recognized..
}
LocaionInfo类在UtilLib.cs中定义,如下所示:
public class LocationInfo
{
public string Altitude{ get; set; }
public string Longitude{ get; set; }
public string Latitude{ get; set; }
}