using System.Windows; using System.Windows.Input; namespace Windowless_Sample { /// /// Provides bindable properties and commands for the NotifyIcon. In this sample, the /// view model is assigned to the NotifyIcon in XAML. Alternatively, the startup routing /// in App.xaml.cs could have created this view model, and assigned it to the NotifyIcon. /// public class NotifyIconViewModel { /// /// Shows a window, if none is already open. /// public ICommand ShowWindowCommand { get { return new DelegateCommand { CanExecuteFunc = () => Application.Current.MainWindow == null, CommandAction = () => { Application.Current.MainWindow = new MainWindow(); Application.Current.MainWindow.Show(); } }; } } /// /// Hides the main window. This command is only enabled if a window is open. /// public ICommand HideWindowCommand { get { return new DelegateCommand { CommandAction = () => Application.Current.MainWindow.Close(), CanExecuteFunc = () => Application.Current.MainWindow != null }; } } /// /// Shuts down the application. /// public ICommand ExitApplicationCommand { get { return new DelegateCommand {CommandAction = () => Application.Current.Shutdown()}; } } } }