16 lines
754 B
C#
16 lines
754 B
C#
using System.Windows.Input;
|
|
|
|
namespace Paca.Avalonia;
|
|
|
|
/// <summary>간단한 ICommand 구현(CommunityToolkit 없이 MVVM 커맨드 바인딩용).</summary>
|
|
public sealed class RelayCommand : ICommand
|
|
{
|
|
private readonly Action<object?> _execute;
|
|
private readonly Func<object?, bool>? _canExecute;
|
|
public RelayCommand(Action<object?> execute, Func<object?, bool>? canExecute = null)
|
|
{ _execute = execute; _canExecute = canExecute; }
|
|
public bool CanExecute(object? parameter) => _canExecute?.Invoke(parameter) ?? true;
|
|
public void Execute(object? parameter) => _execute(parameter);
|
|
public event EventHandler? CanExecuteChanged;
|
|
public void RaiseCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
|
}
|