removed RelayCommand.cs

This commit is contained in:
2020-03-29 22:17:27 +02:00
parent bd7f504a56
commit 97ed0d9be0
2 changed files with 7 additions and 41 deletions

View File

@ -1,35 +0,0 @@
using System;
using System.Windows.Input;
namespace ModernWpfPlayground.MvvmStuff
{
public class RelayCommand : ICommand
{
private readonly Predicate<object>? _canExecute;
private readonly Action<object> _execute;
public RelayCommand(Action<object> execute)
{
_execute = execute;
}
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
_canExecute = canExecute;
_execute = execute;
}
public event EventHandler CanExecuteChanged
{
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
public bool CanExecute(object parameter) => _canExecute?.Invoke(parameter) ?? true;
public void Execute(object parameter)
{
_execute(parameter);
}
}
}