Skip to content

Instantly share code, notes, and snippets.

@zafe
Created April 14, 2020 04:21
Show Gist options
  • Save zafe/ba9035b772ffa74823f6b9da0237fb72 to your computer and use it in GitHub Desktop.
Save zafe/ba9035b772ffa74823f6b9da0237fb72 to your computer and use it in GitHub Desktop.
public class ViewModel : ViewModelBase
{
public ICommand ChangeNameCommand { get; }
...
}
public class DelegateCommand : ICommand
{
private readonly Action<object> _executeAction;
public DelegateCommand(Action<object> executeAction)
{
_executeAction = executeAction;
}
public void Execute(object parameter) => _executeAction(parameter);
public bool CanExecute(object parameter) => true;
public event EventHandler CanExecuteChanged;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment