internal class DelegateCommand : ICommand { public event EventHandler? CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } public DelegateCommand(Action<object?> executeAction, Func<object?, bool>? canExecuteFunc = null) { ExecuteAction = executeAction; CanExecuteFunc = canExecuteFunc; } public bool CanExecute(object? parameter) { return CanExecuteFunc == null || CanExecuteFunc(parameter); } public void Execute(object? parameter) { ExecuteAction?.Invoke(parameter); } public Action<object?>? ExecuteAction { get; set; } public Func<object?, bool>? CanExecuteFunc { get; set; } }
internal class NotificationObject : INotifyPropertyChanged { public event PropertyChangedEventHandler? PropertyChanged; protected void NotifyPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } }
标签:set,MVVM,CanExecuteFunc,executeAction,ExecuteAction,手写,parameter,public From: https://www.cnblogs.com/xlege/p/18173220