I'm using the xamMap control in a similar way as in the sample Seat Chooser (I'm choosing chemical elements out of a periodic table).
The problem is that the map is moved if the user presses the cursor keys on the keyboard. This doesn't make any sense here, because now it's possible to move the complete table out of sight and the user is lucky if he can bring it back. Furthermore I don't think it makes sense to move the map out of sight in any sample at all.
So is there an easy way to prevent the user from moving the map?
A second problem is the zooming of the map via mouse wheel. Is it possible to prevent this too?
You can see what I mean in Seat Chooser sample. Just click into the map and then press a cursor key on the Keyboard multiple times.
TIA Michael
Thank you Andrew. Sometimes one should simply read the docs. All info is there I just didn't read it.
Hello Michael,
I apologize, I hadn't seen the IsZoomable property on the XamMap. Rather than handling the "Preview" events, you can achieve the pan and zoom disabling on the XamMap by setting the IsZoomable and IsPannable properties to "False."
Regarding the "secret voodoo" of XamMap navigation, this is documented in the Map Navigation portion of our Understanding XamMap online documentation article. This area details the ways that the XamMap can be zoomed or panned. Here is a link to that online documentation article: http://help.infragistics.com/Help/Doc/WPF/2012.1/CLR4.0/html/xamWebMap_Understanding_xamWebMap.html.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello Andrew,
for the zoom issue I found that XamMap has a flag called IsZoomable, which I can set to False.
Your solution to catch PreviewKeyDown works for my situation, because I always display the complete map. But I don't think someone who displays e.g. a zoomable world map would be so happy, if the user can't move the map. There it would be better to have a flag called DisableOutOfBounds or similar.
A second concern is, how can I be sure that the cursor keys are the only way to move the map? Maybe there is some secret voodoo that I don't know about yet, e.g. some touch gestures?
Anyway, thank you for your help.
Thank you for your post.
To achieve your requirements for blocking the keyboard cursor panning and the mouse wheel zooming, I would recommend handling the PreviewMouseWheel and PreviewKeyDown events on the XamMap control.
In the PreviewKeyDown event, you can check the e.Key property of the event arguments to see if the key pressed was one of the directional cursor keys. If it was, you can set the e.Handled property to true. This will prevent the XamMap from getting to the actual KeyDown event, which will pan the map if one of the keys pressed was a keyboard cursor key.
In the PreviewMouseWheel event, you simply need to set the e.Handled property to true. This will prevent the XamMap from getting to the MouseWheel event, which will stop the mouse wheel zooming.
Please let me know if you have any other questions or concerns on this matter.