Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created October 23, 2019 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/b4eacbfddfec72a877dcb1b970c87d2f to your computer and use it in GitHub Desktop.
Save IntegerMan/b4eacbfddfec72a877dcb1b970c87d2f to your computer and use it in GitHub Desktop.
public class ActionCommand : ICommand
{
private readonly Action<object> _invokedAction;
public ActionCommand(Action invokedAction)
{
_invokedAction = _ => invokedAction?.Invoke();
}
public ActionCommand(Action<object> invokedAction)
{
_invokedAction = invokedAction;
}
public bool CanExecute(object parameter) => true;
public void Execute(object parameter) => _invokedAction?.Invoke(parameter);
public event EventHandler CanExecuteChanged;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment