🌈 搜索
📅  最后修改于: 2022-03-11 14:48:45.204000             🧑  作者: Mango
public class RelayCommand : ICommand { private readonly Predicate _canExecute; private readonly Action _execute; public RelayCommand(Predicate canExecute, Action execute) { this._canExecute = canExecute; this._execute = execute; } public event EventHandler CanExecuteChanged { add => CommandManager.RequerySuggested += value; remove => CommandManager.RequerySuggested -= value; } public bool CanExecute(object parameter) { return _canExecute(parameter); } public void Execute(object parameter) { _execute(parameter); } }