using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; namespace 常用工具集.Base { public class DelegateCommand : ICommand { public Action ExecuteCommand = null; public Func CanExecuteCommand = null; public event EventHandler CanExecuteChanged; public DelegateCommand() { } public DelegateCommand(Action Command) { ExecuteCommand = Command; } public bool CanExecute(object paramter) { if (CanExecuteCommand != null) { return CanExecuteCommand(paramter); } else { return true; } } public void Execute(object paramter) { if (ExecuteCommand != null) ExecuteCommand(paramter); } public void RaiseCanExecuteChanged() { if (CanExecuteChanged != null) CanExecuteChanged(this, EventArgs.Empty); } } }