Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
475
Howto block keyboard cursor keys?
posted

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

Parents
No Data
Reply
  • 34810
    Verified Answer
    Offline posted

    Hello Michael,

    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.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

Children