WPF, PreviewKeyDown event and underscore char
Posted
by commanderz
on Stack Overflow
See other posts from Stack Overflow
or by commanderz
Published on 2010-05-27T21:05:56Z
Indexed on
2010/05/28
2:51 UTC
Read the original article
Hit count: 1227
Hi,
I'm catching key hits with PreviewKeyDown event in my WPF component. I need to distinguish characters being typed: letters vs. numbers vs. underscore vs. anything else.
Letters and numbers work fine (just convert the Key property of the KeyEventArgs object to string and work with character 0 of that string), but this won't work for underscore.
It's ToString value depends on localized keyboard settings (it shows up as "OemMinus" on EN/US keyboard and "OemQuestion" on CZ/QWERTY keyboard).
So how can I RELIABLY find out, if the typed char is underscore in the PreviewKeyDown event?
Thanks for any help
© Stack Overflow or respective owner