转换System.Windows.Input.KeyEventArgs键为char [英] Convert a System.Windows.Input.KeyEventArgs key to a char
本文介绍了转换System.Windows.Input.KeyEventArgs键为char的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要得到事件参数为字符
,但是当我试图铸造重点枚举我得到完全不同的字母和比中传递的符号。
I need to get the event args as a char
, but when I try casting the Key enum I get completely different letters and symbols than what was passed in.
你如何正确转换的关键字符?
How do you properly convert the Key to a char?
这是我已经试过
ObserveKeyStroke(this, new ObervableKeyStrokeEvent((char)((KeyEventArgs)e.StagingItem.Input).Key));
编辑:我还没有对ARGS的键码属性。 。我让他们从InputManager.Current.PreNotifyInput事件
I also don't have the KeyCode property on the args. I'm getting them from the InputManager.Current.PreNotifyInput event.
推荐答案
请参阅如何将一个字符等效System.Windows.Input转换。键枚举值?
使用 KeyInterop.VirtualKeyFromKey
代替。
这篇关于转换System.Windows.Input.KeyEventArgs键为char的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文