using System; using System.Windows.Input; namespace MSFSPopoutPanelManager.WpfApp.ViewModel { public class DelegateCommand : ICommand { private readonly Action _executeAction; private readonly Func _canExecuteAction; public DelegateCommand(Action executeAction, Func canExecuteAction) { _executeAction = executeAction; _canExecuteAction = canExecuteAction; } public void Execute(object parameter) => _executeAction(parameter); public bool CanExecute(object parameter) => _canExecuteAction?.Invoke(parameter) ?? true; public event EventHandler CanExecuteChanged; public void InvokeCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty); } }