Although I have understood async programming with c# somehow, still don\'t get why async with void is not the better solution, then when I want to improve my Xamarin Forms code
To anyone interested: Brandons solution above does not requery the CanExecute automatically and requires RaiseCanExecuteChanged(). To change this, you can exchange
public event EventHandler CanExecuteChanged
{
add => _weakEventManager.AddEventHandler(value);
remove => _weakEventManager.RemoveEventHandler(value);
}
with
public event EventHandler CanExecuteChanged {
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
and remove
public void RaiseCanExecuteChanged() => _weakEventManager.HandleEvent(this, EventArgs.Empty, nameof(CanExecuteChanged));
This fixed the problem for me.