using System; using System.Windows.Input; namespace VBASync.WPF { internal class WpfCommand : ICommand { private readonly Func _canExecute; private readonly Action _command; internal WpfCommand(Action command, Func canExecute = null) { _command = command; _canExecute = canExecute ?? (v => true); } public event EventHandler CanExecuteChanged; public bool CanExecute(dynamic parameter) => _canExecute(parameter); public void Execute(dynamic parameter) => _command(parameter); public void OnExecuteChanged() => CanExecuteChanged?.Invoke(this, new EventArgs()); } }