Drag a Graphic or Feature Using Mouse (WPF/v100.2)

1302
4
03-22-2018 08:12 AM
KeithGemeinhart1
New Contributor III

I'd like to select a feature, and then click & hold the mouse button to drag it to a new location, setting the new location when the mouse button is released. However, the mouse move events don't seem to be firing when the left mouse button is held down. I suspect this is related to the map panning operation, which is also done with mouse-down-drag-release sequence. But, it's the same with the right mouse button held down.

I tried turning off panning with this code, but no luck. Still no mouse move events.

MainMapView.InteractionOptions = new MapViewInteractionOptions();
MainMapView.InteractionOptions.IsPanEnabled = false;‍‍

I also tried right mouse button down with sketch editor active and again no mouse events.

Is there any way for me to get mouse move events with either of the buttons held down?

0 Kudos
4 Replies
AaronMurphy3
New Contributor III

I wanted to do this a while ago. I instead settled with clicking the graphic which then "picked it up" and then I could move my mouse round and then click again when I wanted to place it. It wasn't quite drag and drop, but it was very close.

0 Kudos
KeithGemeinhart1
New Contributor III

I'm working on a similar kind of workaround, but it's an awkward, unusual interaction for the user.

0 Kudos
AaronMurphy3
New Contributor III

Yeah, it's not ideal. My process goes:

> Turn on graphic editing

> Click marker (highlights it blue)

> Press "Move Marker" button

> Marker now moves with the mouse

> Click map to place in new spot

> Press save

Ugly, but works.

0 Kudos
BikeshMaharjan1
New Contributor III

I created a similar application where I needed to drag the graphic.

Used mouse events: Mouse down(identify and ready for moving it), Mouse move (check if the mouse is still down while moving, which is drag) , and Mouse up(Confirmation popup). There might be better ways but this worked for me.

Along with disabling the map pan, in mouse down event, you can use Mouse.Capture(null) which releases the mouse down event and mouse move event can be captured.

Hope this gives some ideas!

Thanks,

Bikesh

0 Kudos