开发者

How to launch RoutedCommand on application level in multiple windows pattern?

开发者 https://www.devze.com 2023-01-06 03:13 出处:网络
I have a multiple windows in an application, for instance, window1, window2 and window3. one RoutedCommand (with KeyGesture F11) was binded in window1.

I have a multiple windows in an application, for instance, window1, window2 and window3.

one RoutedCommand (with KeyGesture F11) was binded in window1. How to launch that routed command by pressing F11, while window2 had input focus ?

In WinForm application, i use MessageFilter to detect F11, but in WPF, ho开发者_开发问答w to do that ?


You can use CommandManager.RegisterClassCommandBinding to hook up a handler to every Window application wide. This will be continue working for the rest of your application run so it usually makes sense to put it in App.xaml.cs but you could put it anywhere.

CommandManager.RegisterClassCommandBinding(typeof(Window), new CommandBinding(ApplicationCommands.Cut, CutExecuted));
0

精彩评论

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