Windows phone 7 如何在windows phone中手动调用位置更改方法?

Windows phone 7 如何在windows phone中手动调用位置更改方法?,windows-phone-7,windows-phone-8,windows-phone-7.1,windows-phone,bing-maps,Windows Phone 7,Windows Phone 8,Windows Phone 7.1,Windows Phone,Bing Maps,我有下面的事件,它在geocoordinatewatcher对象位置更改事件中被触发 void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) { //do the stuff here } void watcher\u位置已更改(对象发送器,地理位置更改Deventargs e) { //在这里做事 } 现在,当用户点击地图上的任何位置时,我想

我有下面的事件,它在geocoordinatewatcher对象位置更改事件中被触发

 void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)

 {
   //do the stuff here
 }
void watcher\u位置已更改(对象发送器,地理位置更改Deventargs e)
{
//在这里做事
}
现在,当用户点击地图上的任何位置时,我想调用上面的方法,每次都做同样的事情。
知道如何实现这一点吗?

手动调用事件处理程序:

var position = new GeoPosition<GeoCoordinate>(DateTimeOffset.Now, new GeoCoordinate(32, 64));

this.watcher_PositionChanged(this, new GeoPositionChangedEventArgs<GeoCoordinate>(position));
var position=新地理位置(DateTimeOffset.Now,新地理坐标(32,64));
此.watcher_位置已更改(此,新地理位置更改Deventargs(位置));
或者重写事件处理程序,将逻辑放入另一个方法中,然后调用它:

void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
    this.UpdatePosition(e.Position);
}

private void UpdatePosition(GeoCoordinate coordinates)
{
    // Do the stuff here
}
void watcher\u位置已更改(对象发送器,地理位置更改Deventargs e)
{
此。更新位置(即位置);
}
专用空心更新位置(地理坐标)
{
//在这里做事
}

这样,您只需随时调用
UpdatePosition
。我建议使用此解决方案,它比第一个更干净。

手动调用事件处理程序:

var position = new GeoPosition<GeoCoordinate>(DateTimeOffset.Now, new GeoCoordinate(32, 64));

this.watcher_PositionChanged(this, new GeoPositionChangedEventArgs<GeoCoordinate>(position));
var position=新地理位置(DateTimeOffset.Now,新地理坐标(32,64));
此.watcher_位置已更改(此,新地理位置更改Deventargs(位置));
或者重写事件处理程序,将逻辑放入另一个方法中,然后调用它:

void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
    this.UpdatePosition(e.Position);
}

private void UpdatePosition(GeoCoordinate coordinates)
{
    // Do the stuff here
}
void watcher\u位置已更改(对象发送器,地理位置更改Deventargs e)
{
此。更新位置(即位置);
}
专用空心更新位置(地理坐标)
{
//在这里做事
}
这样,您只需随时调用
UpdatePosition
。我推荐这个解决方案,它比第一个更干净