c# - How to disable focus changes by arrow keys -


i have wpf window few controls (buttons, groupboxes, etc) , 1 big viewport3d within border.

the viewport shows 3d scene , want arrow keys move camera around. problem: arrow keys change focus uielement.

how can disable focus changes arrow keys , have them change camera position instead?

it difficult answer without having code test, because without it, guessing really. either way, can't comment on particular situation, in general, if want stop pre-defined action happening in event, typically handle event , set e.handled property true.

seeing want handle keydown event detect use of arrow keys, set e.handled property true @ same time. however, should handle previewkeydown event instead, because occurs before keydown event , more have effect want. try this:

private void textbox_previewkeydown(object sender, keyeventargs e) {     if (e.key == key.left || e.key == key.right)     {         // move camera here         e.handled = true;     } } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -