RelayCommand.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Windows.Input; 7 8 namespace PowerLauncher.ViewModel 9 { 10 public class RelayCommand : ICommand 11 { 12 private readonly Action<object> _action; 13 14 public RelayCommand(Action<object> action) 15 { 16 _action = action; 17 } 18 19 public virtual bool CanExecute(object parameter) 20 { 21 return true; 22 } 23 24 public event EventHandler CanExecuteChanged 25 { 26 add { } 27 remove { } 28 } 29 30 public virtual void Execute(object parameter) 31 { 32 _action?.Invoke(parameter); 33 } 34 } 35 }