c# - KeyDown Events in WPF Application only work with Focus -


i have calculator wpf interface, , there grid containing of buttons. want these buttons react to, say, numpad keys, among others. created keydown events of them, works when button key press focused. read keypreview property, exists windows forms, correct? feel need change property of buttongrid, can't figure out. relatively new programming way.

edit: 1 of methods, how generic method like? onlydigitsintextbox custom method consisting of .appendtext extension method.

private void button6_key(object sender, keyeventargs e)     {         if (e.key == key.numpad6)         {             onlydigitsintextbox("6");         }     } 

best approach use custom commands keybindings.

wpf custom commands

wpf keybindings


Comments