开发者

Multiple key binding in WPF

开发者 https://www.devze.com 2022-12-30 12:16 出处:网络
How can i execute some command on, lets say, C开发者_如何学Ctrl+Shift+E? As i saw we can write the following:

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

精彩评论

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