You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/WPFExamples/RelayCommand.cs

34 lines
860 B

using System;
namespace ZeroLevel.WPF
{
public class RelayCommand
: System.Windows.Input.ICommand
{
private readonly Predicate<object> _canExecute;
private readonly Action<object> _execute;
public RelayCommand(Predicate<object> canExecute, Action<object> execute)
{
_canExecute = canExecute;
_execute = execute;
}
public event EventHandler CanExecuteChanged
{
add => System.Windows.Input.CommandManager.RequerySuggested += value;
remove => System.Windows.Input.CommandManager.RequerySuggested -= value;
}
public bool CanExecute(object parameter)
{
return _canExecute(parameter);
}
public void Execute(object parameter)
{
_execute(parameter);
}
}
}

Powered by TurnKey Linux.