3

I need to handle Ctrl+F keys combo to invoke search function inside my TabControl.

OnKeyDown() called for each button pressed, but how I can handle combination of two buttons?

Mykola
  • 3,343
  • 6
  • 23
  • 39
Constantine
  • 1,802
  • 3
  • 23
  • 37

1 Answers1

4

Just put this in your xaml :

<Window.InputBindings>
 <KeyBinding Command="ApplicationCommands.YourCommandToHandle"
       Gesture="CTRL+F" />
</Window.InputBindings>
Vasilievski
  • 773
  • 6
  • 13
  • My Window have 3 tabs, I need this shortcut only on one of them. Is it possible? – Constantine Jan 25 '16 at 16:02
  • Yes indeed you can. I can see two solution to my mind. You can make a binding between your SelectedItem in your TabControl and CanExecute in your Command through a converter. Else you can put a condition on the SelectedItem in your Command (by its key or what so ever), but it's not really MVVM. – Vasilievski Jan 25 '16 at 16:56