locked
Bing Maps WPF - MouseUp event not firing when handling MouseMove event RRS feed

  • Question

  • I've developed a WPF app using Bing Maps WPF. I'm trying to move a polygon drawn on the map by having the user click on the polygon, and while holding own the mouse button, dragging the polygon across the screen. When he releases the mouse button, I perform some actions.

    My problem is that, when dragging the polygon, I set the bingMap_MouseMove event to

    e.Handled = true;

    to stop the user from dragging the entire map. However, once I do this, when he releases the mouse button, now the bingMap_MouseUp event doesn't fire anymore.

    Any ideas? Thanks...


    Fabricio Rodriguez - Pretoria, South Africa

    Sunday, January 18, 2015 7:49 PM

Answers

  • Try this instead. When the user presses the mouse button down, capture the current zoom/center position. Also create a Boolean flag to indicate that a polygon has been selected. Then add a viewchange event and if the boolean flag is set to true, set the center and zoom of the map to the values captured when the mouse was pressed. This will lock the map to a single position. When the mouse is released set the Boolean value to false to free the map.

    You might find this code sample useful: https://code.msdn.microsoft.com/Draggable-Pushpins-in-Bing-48cb2683


    http://rbrundritt.wordpress.com

    Monday, January 19, 2015 6:10 PM

All replies

  • Try this instead. When the user presses the mouse button down, capture the current zoom/center position. Also create a Boolean flag to indicate that a polygon has been selected. Then add a viewchange event and if the boolean flag is set to true, set the center and zoom of the map to the values captured when the mouse was pressed. This will lock the map to a single position. When the mouse is released set the Boolean value to false to free the map.

    You might find this code sample useful: https://code.msdn.microsoft.com/Draggable-Pushpins-in-Bing-48cb2683


    http://rbrundritt.wordpress.com

    Monday, January 19, 2015 6:10 PM
  • Thanks Ricky! That's just what I was looking for!

    Fabricio Rodriguez - Pretoria, South Africa

    • Marked as answer by Fabs1977 Tuesday, January 20, 2015 12:35 PM
    • Unmarked as answer by Ricky_Brundritt Tuesday, January 20, 2015 4:15 PM
    Tuesday, January 20, 2015 12:35 PM