开发者

Multiple key binding in WPF

How can i execute some command on, lets say, C开发者_如何学Ctrl+Shift+E? As i saw we can write the following:

KeyBinding kb = new KeyBinding(TestCommand, Key.E, ModifierKeys.Control);
this.InputBindings.Add(kb);

But how can i add more ModifierKeys or Keys?


ModifiedKeys is a flags enumeration, so you can combine its values with the logical OR operator (|) as follows:

KeyBinding kb = new KeyBinding(TestCommand, Key.E, ModifierKeys.Control | ModifierKeys.Shift);
this.InputBindings.Add(kb);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜