15 lines
441 B
C#
15 lines
441 B
C#
using System.Windows.Input;
|
|
|
|
namespace Zcbot.WindowsNode;
|
|
|
|
internal sealed class RelayCommand(Action execute, Func<bool>? canExecute = null) : ICommand
|
|
{
|
|
public event EventHandler? CanExecuteChanged;
|
|
|
|
public bool CanExecute(object? parameter) => canExecute?.Invoke() ?? true;
|
|
|
|
public void Execute(object? parameter) => execute();
|
|
|
|
internal void RaiseCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
|
}
|