Dreamine.PLC.Wpf 1.0.1
Dreamine.PLC.Wpf 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
DelegateCommand.cs
이 파일의 문서화 페이지로 가기
1using System.Windows.Input;
2
4
13public sealed class DelegateCommand : ICommand
14{
23 private readonly Action<object?> _execute;
32 private readonly Predicate<object?>? _canExecute;
33
66 public DelegateCommand(Action<object?> execute, Predicate<object?>? canExecute = null)
67 {
68 _execute = execute ?? throw new ArgumentNullException(nameof(execute));
69 _canExecute = canExecute;
70 }
71
80 public event EventHandler? CanExecuteChanged;
81
106 public bool CanExecute(object? parameter)
107 {
108 return _canExecute?.Invoke(parameter) ?? true;
109 }
110
127 public void Execute(object? parameter)
128 {
129 if (CanExecute(parameter))
130 {
131 _execute(parameter);
132 }
133 }
134
144 {
145 CanExecuteChanged?.Invoke(this, EventArgs.Empty);
146 }
147}
DelegateCommand(Action< object?> execute, Predicate< object?>? canExecute=null)
readonly? Predicate< object?> _canExecute