3using System.Windows.Input;
26 _execute = execute ??
throw new ArgumentNullException(nameof(execute));
75 var tuple = ((
RelayCommand cmd, EventHandler evt))state!;
76 tuple.evt.Invoke(tuple.cmd, EventArgs.Empty);
83 handler.Invoke(
this, EventArgs.Empty);
103 public RelayCommand(Action<T> execute, Func<T, bool>? canExecute =
null)
106 _execute = execute ??
throw new ArgumentNullException(nameof(execute));
139 throw new ArgumentException($
"Command parameter is not assignable to {typeof(T).FullName}.", nameof(parameter));
168 tuple.evt.Invoke(tuple.cmd, EventArgs.Empty);
174 handler.Invoke(
this, EventArgs.Empty);
186 if (parameter is
null)
189 if (
default(T) is
null)
201 if (parameter is T t)
readonly Action< T > _execute
bool CanExecute(object? parameter)
명령이 현재 실행 가능한지를 결정합니다.
void RaiseCanExecuteChanged()
CanExecute 상태를 수동으로 갱신합니다. UI 스레드가 아닌 스레드에서 호출되더라도 UI 스레드로 안전하게 마샬링합니다.
static bool TryGetParameter(object? parameter, out T value)
ICommand parameter를 T 로 안전하게 변환합니다.
readonly? SynchronizationContext _syncContext
readonly? Func< T, bool > _canExecute
void Execute(object? parameter)
명령을 실행합니다.
EventHandler? CanExecuteChanged
명령의 실행 가능 상태가 변경되었음을 알리는 이벤트입니다. UI 바인딩 요소는 이 이벤트를 통해 CanExecute 상태를 다시 평가합니다.
RelayCommand(Action< T > execute, Func< T, bool >? canExecute=null)
RelayCommand 생성자
EventHandler? CanExecuteChanged
명령의 실행 가능 상태가 변경될 때 발생하는 이벤트입니다.
void RaiseCanExecuteChanged()
CanExecute 상태를 수동으로 갱신합니다. UI 스레드가 아닌 스레드에서 호출되더라도 UI 스레드로 안전하게 마샬링합니다.
readonly? Func< bool > _canExecute
void Execute(object? parameter)
명령을 실행합니다.
readonly? SynchronizationContext _syncContext
bool CanExecute(object? parameter)
현재 명령이 실행 가능한지를 나타냅니다.
RelayCommand(Action execute, Func< bool >? canExecute=null)
RelayCommand 생성자