Mvvm
Mvvm copied to clipboard
How to use AsyncCommand canExecuteChangedFactory?
I'm trying to use pre3
and it seems that I cannot pass a simple function any more as the the second parameter for the AsyncCommand as you have suggested here: https://github.com/StephenCleary/Mvvm.Async/issues/11#issuecomment-259687116
What is the expected way of using the factory in pre3
release?
The factory is a specific implementation of the CanExecuteChanged event (not it's logic).
The current AsyncCommand class always ties CanExecute to IsExecuting. If you need different logic, you'd need to derive a custom type from AsyncCommandBase.
Hope this helps, -Steve
Thanks for the hint. I didn't understand that from the comments.
So this means that if a command shall only execute on a certain pre-condition you would expect a new property to be introduced and that bound to the IsEnabled
property in the XAML?
bool CanExecuteCommandX => !AsynCommandGenerateX.IsExecuting && otherCondition
That seems overly cumbersome and against most examples and books about WPF and the Command parameter.
It's overly cumbersome and sort of against the idea of even taking delegate arguments if I have to derive a new type to support CanExecuteChanged.
Extant conversations and StackOverflow discussions seem to indicate the OnCanExecuteChanged() method used to be public. Why did it change to protected?