protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Create a new instance of the main window. var mainWindow = new MainWindow(); Application.Current.MainWindow = mainWindow; if (e.Args.Any(arg => arg.ToUpper().Equals("/refresh"))) { mainWindow.Refresh(); } //create the notifyicon (it's a resource declared in SystemTray/SystemTrayResources.xaml). _taskBarIcon = (TaskbarIcon)FindResource("SystemTrayIcon"); // Register the hot-key that will show the application HotKeyManager.Register( Key.Space, OperatingSystem.KeyModifier.Alt, () => { var command = GlobalCommands.ShowWindowCommand(); if (command.CanExecute(null)) { command.Execute(null); } }); }