Disabling Map Mouse Events

2274
5
12-09-2010 09:46 AM
AndyWright
Occasional Contributor
I have written a user control that displays a tree view and a data grid for a selected feature.  The graphic for that feature is on an element layer, and when the user hovers over that graphic my user control is animated out from that graphic to display the feature's attributes in the tree view/data grid.  That is all working great.

The problem I am having is with map mouse events.  I have a grid splitter on my user control that allows the user to resize the two halves of the control.  While I am dragging the grid splitter the map pans in the background.  I also have a similar issue when I am using my mouse roller wheel to scroll up and down in my data grid.  When I get to the top or bottom of the data grid the map starts to zoom in and out.

So what is going on is that the map mouse events are still firing even though I'm over top of my user control.  I am thinking that because the user control is on an element layer, which is part of the map, my mouse is technically still over the map when it's over the user control. 

What I would like to do is disable all mouse interaction with the map when the mouse has entered my user control and then re-enable all map mouse interaction when it has left my user control.  I have been unable to find a quick and dirty way to do that up to this point.  I've tried setting the IsHitTestVisible property for the map to false - that didn't work.  I also tried ReleaseMouseCapture on the map as well and that didn't work either.

Can someone point me in the right direction here?  Thanks a ton ...
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
In the UserControl child of ElementLayer, subscribe to MouseLeftButtonDown and MouseWheel and mark them e.Handled = true.
0 Kudos
AndyWright
Occasional Contributor
Jennifer,

Thanks for the suggestion.  The MouseLeftButtonDown part is working like a charm, but the MouseWheel event never fires for me.  Any ideas there?


void ResultGraphic()
{
    map.MouseWheel += new MouseWheelEventHandler(map_MouseWheel);
}

void map_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (_overCanvas)
            {
                e.Handled = true;
            }
        }

0 Kudos
AndyWright
Occasional Contributor
Jennifer,

Unfortunately I think I found the answer to my question in this thread ...

http://forums.arcgis.com/threads/12027-MouseWheel-support-in-Silverlight?highlight=mousewheel

I am using the 2.0 API.  Is this still the case in 2.1?  It seems like the ability to tap into the MouseWheel event should be there out of the box.  The developer should have the ability to decide what he/she wants to do with it rather than you guys disabling our access to that event altogether.

Are there any workarounds?
0 Kudos
JenniferNery
Esri Regular Contributor
The MouseWheel on the Map cannot be marked handled as explained in this thread: http://forums.arcgis.com/threads/12027-MouseWheel-support-in-Silverlight

What you can do is mark this handled on the element's MouseWheel. However that also means MouseWheel cannot be used to scroll up/down in your user control.

To clarify - In my previous post, the mouse events are on the element itself, not the map.
0 Kudos
AndyWright
Occasional Contributor
Jennifer,

When I tie into the MouseWheel event for the user control rather than the map everything works great.  I can even still use my mouse wheel in the data grid on the user control.  Interesting behavior.  Thanks for all your help ...
0 Kudos