views:

29

answers:

1

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, how to do that ?

A: 

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));
John Bowen
Very good! it works!