e.UserState在Windows Phone应用程序的已完成事件中不可用

时间:2013-10-15 14:24:24

标签: c# windows-phone-7 windows-phone-8 windows-phone windows-phone-7.1

我正在尝试为我在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; }
   }

0 个答案:

没有答案