Aufgabe Timer in Titel
This commit is contained in:
44
FahzeugWPF/RelayCommand.cs
Normal file
44
FahzeugWPF/RelayCommand.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
namespace FahzeugWPF;
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Input;
|
||||
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
readonly Action<object> _execute = null;
|
||||
readonly Predicate<object> _canExecute = null;
|
||||
|
||||
public RelayCommand(Action<object> execute)
|
||||
: this(execute, null)
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
|
||||
{
|
||||
if (execute == null)
|
||||
{
|
||||
throw new ArgumentNullException("execute");
|
||||
}
|
||||
|
||||
this._execute = execute;
|
||||
this._canExecute = canExecute;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return _canExecute == null ? true : _canExecute(parameter);
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute(parameter);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user