public class RelayCommand : ICommand
{
private readonly Action _execute;
private readonly Func<bool> _canExecute;
public RelayCommand(Action execute,Func<bool> canExecute)
{
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
_canExecute = canExecute;
}
public RelayCommand(Action execute)
: this(execute, null) {
}
public event EventHandler CanExecuteChanged
实现ICommand接口
最新推荐文章于 2024-01-02 01:09:32 发布
本文详细介绍了如何在C#中实现WPF和MVVM模式中常用的ICommand接口,包括其作用、使用场景以及具体的实现步骤,帮助开发者更好地理解和应用这一功能。
摘要由CSDN通过智能技术生成