Question
I would like to assign the keyboard shortcut Ctrl + , (control plus comma) to the "Preferences..." menu item. How do I do that?
有一个Key.OemComma
in the Key http://msdn.microsoft.com/en-us/library/system.windows.input.key.aspx枚举。我用过Key.OemComma
如下面的代码示例所示。从功能上来说,这工作得很好。但 GUI 方面:菜单项显示为
代替
示例代码
InputGestureCollection keyInputs = new InputGestureCollection();
keyInputs.Add(new KeyGesture(Key.OemComma, ModifierKeys.Control));
preferencesCommand = new RoutedUICommand("Preferences...", "Preferences", typeof(MyCommands), keyInputs);
我觉得按键手势构造函数 http://msdn.microsoft.com/en-us/library/aa345788.aspx需要一个显示字符串就可以了。你可以这样称呼它:
InputGestureCollection keyInputs = new InputGestureCollection();
keyInputs.Add(new KeyGesture(Key.OemComma, ModifierKeys.Control, "Ctrl+,"));
preferencesCommand = new RoutedUICommand("Preferences...", "Preferences", typeof(MyCommands), keyInputs);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)