Dreamine.Communication.Wpf 1.0.2
Dreamine.Communication.Wpf 통신 기능과 관련 API를 제공합니다.
로딩중...
검색중...
일치하는것 없음
DelegateCommand.cs
이 파일의 문서화 페이지로 가기
1using System;
2using System.Windows.Input;
3
5
14public sealed class DelegateCommand : ICommand
15{
24 private readonly Action<object?> _execute;
33 private readonly Predicate<object?>? _canExecute;
34
67 public DelegateCommand(Action<object?> execute, Predicate<object?>? canExecute = null)
68 {
69 _execute = execute ?? throw new ArgumentNullException(nameof(execute));
70 _canExecute = canExecute;
71 }
72
81 public event EventHandler? CanExecuteChanged;
82
107 public bool CanExecute(object? parameter)
108 {
109 return _canExecute?.Invoke(parameter) ?? true;
110 }
111
128 public void Execute(object? parameter)
129 {
130 _execute(parameter);
131 }
132
142 {
143 CanExecuteChanged?.Invoke(this, EventArgs.Empty);
144 }
145}
DelegateCommand(Action< object?> execute, Predicate< object?>? canExecute=null)