I am developing a WPF application, it is kept minimized in the system tray and I want the window to open when a shortcut is pressed (example: Ctrl + Space).
I have tried using CommandBindings but it only works when the window has the focus, I want the window to stay hidden and show only when the shortcut is pressed.
Xaml Code:
<CommandBinding Command="{x:Static local:SearchWindow.ShowWindowCommand}" Executed="ShowWindowCommandExecuted"/>
C# Code:
public SearchWindow()
{
ShowWindowCommand.InputGestures.Add(new KeyGesture(Key.Space, ModifierKeys.Control));
InitializeComponent();
}
private void ShowWindowCommandExecuted(object sender, ExecutedRoutedEventArgs e)
{
Show();
}