I can't figure out how to use the CanExecuteChangedEventManager in MyCommand : ICommand.
I tried the following but value is the wrong type:
public event EventHandler CanExecuteChanged
{
add
{
CanExecuteChangedEventManager.AddHandler(this, value);
}
remove
{
CanExecuteChangedEventManager.RemoveHandler(this, value);
}
}
The class I'm writing will look like this but without leaks if possible:
public class ManualRelayCommand : ICommand
{
// CanExecute() and Execute() excluded
public event EventHandler CanExecuteChanged;
public virtual void RaiseCanExecuteChanged()
{
var handler = CanExecuteChanged;
if (handler != null)
{
Application.Current.Dispatcher.InvokeAsync(() => handler(this, EventArgs.Empty));
}
}
}