using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Input; namespace UAS_Web.tool { class CustomCommand : ICommand { Action _TargetExecuteMethod; Func _TargetCanExecuteMethod; public event EventHandler CanExecuteChanged = delegate { }; public CustomCommand(Action executeMethod) { _TargetExecuteMethod = executeMethod; } bool ICommand.CanExecute(object parameter) { if (_TargetCanExecuteMethod != null) { return _TargetCanExecuteMethod(); } if (_TargetExecuteMethod != null) { return true; } return false; } public void RaiseCanExecuteChanged() { CanExecuteChanged(this, EventArgs.Empty); } void ICommand.Execute(object parameter) { _TargetExecuteMethod?.Invoke(); } } }