wabbajack/Wabbajack/LambdaCommand.cs

29 lines
624 B
C#
Raw Normal View History

2019-07-31 03:59:19 +00:00
using System;
using System.Windows.Input;
namespace Wabbajack
{
internal class LambdaCommand : ICommand
{
2019-09-14 04:35:42 +00:00
private readonly Func<bool> _canExecute;
private readonly Action _execute;
2019-07-31 03:59:19 +00:00
public LambdaCommand(Func<bool> canExecute, Action execute)
{
_execute = execute;
_canExecute = canExecute;
}
2019-09-14 04:35:42 +00:00
public event EventHandler CanExecuteChanged;
2019-07-31 03:59:19 +00:00
public bool CanExecute(object parameter)
{
return _canExecute();
}
public void Execute(object parameter)
{
_execute();
}
}
}