WPF MVVM模式开发实现简明教程 3-1 BaseCommand
namespace WpfApp6.ViewModel { using System; using System.Windows.Input; ////// 命令基类 /// public class BaseCommand : ICommand { public event EventHandler CanExecuteChanged { add { if (_canExecute != null) { CommandManager.RequerySuggested += value; } } remove { if (_canExecute != null) { CommandManager.RequerySuggested -= value; } } } public bool CanExecute(object parameter) { if (_canExecute == null) { return true; } return _canExecute(parameter); } public void Execute(object parameter) { if (_execute != null && CanExecute(parameter)) { _execute(parameter); } } private Func
网上的代码,主要是Execute,CanExecute,不过不需要理解的,知道需要这个东西就行
原文:https://www.cnblogs.com/jhlong/p/14148911.html