自定义CommandHandler
class CommandHandler : ICommand { Action action; Action<object> action1; Predicate<object> canexecute; bool withparam; bool _canexecute; public CommandHandler(Action act) { action = act; _canexecute = true; withparam = false; } public CommandHandler(Action<object> act, Predicate<object> canexe) { action1 = act; canexecute = canexe; withparam = true; } public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter) { if (withparam) return canexecute(parameter); else return _canexecute; } public void Execute(object parameter) { if (withparam) action1(parameter); else action(); } }
把圈子变小,把语言变干净,把成绩往上提,把故事往心里收,现在想要的以后你都会有。