Skip to content

Instantly share code, notes, and snippets.

@atzimler
Created May 31, 2017 09:57
Show Gist options
  • Save atzimler/15d28af52caf3570142d894a6ea455f0 to your computer and use it in GitHub Desktop.
Save atzimler/15d28af52caf3570142d894a6ea455f0 to your computer and use it in GitHub Desktop.
public class TestCommand : ICommand
{
private bool _whatShouldWeReturnForCanExecute;
public bool WhatShouldWeReturnForCanExecute
{
get => _whatShouldWeReturnForCanExecute;
set
{
if (_whatShouldWeReturnForCanExecute == value)
{
return;
}
_whatShouldWeReturnForCanExecute = value;
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}
public bool CanExecute(object parameter)
{
return _whatShouldWeReturnForCanExecute;
}
public void Execute(object parameter)
{
MessageBox.Show("TestCommand executed");
}
public event EventHandler CanExecuteChanged;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment