MapControl事件未触发;检测用户互动

时间:2017-07-30 12:14:31

标签: c# uwp

我想检测用户何时开始拖动MapControl以从屏幕中心分离,但是Drag*事件中没有一个被触发。

 map.MapTapped += Map_MapTapped;
 map.ActualCameraChanged += Map_ActualCameraChanged;
 map.DragEnter += Map_DragEnter;
 map.DragStarting += Map_DragStarting;
 map.DragLeave += Map_DragLeave;
 map.DragOver += Map_DragOver;
 map.ManipulationStarted += Map_ManipulationStarted;
 map.Tapped += Map_Tapped;
 map.PointerPressed += Map_PointerPressed;
 map.PointerMoved += Map_PointerMoved;

我看到的唯一事件是MapTappedActualCameraChanged,但是当我需要时,这些事件都不会触发。

1 个答案:

答案 0 :(得分:0)

拖动时使用ActualCameraChanging上升事件

<Maps:MapControl Name="MyMap" ActualCameraChanging="MyMap_ActualCameraChanging"/>

使用ChangeReason检查拖动原因

private void MyMap_ActualCameraChanging(MapControl sender, MapActualCameraChangingEventArgs args)
{
    if(args.ChangeReason == MapCameraChangeReason.UserInteraction)
    {
        //...
    }
}