Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use AsyncCommand canExecuteChangedFactory? #26

Open
RedX2501 opened this issue Dec 6, 2019 · 3 comments
Open

How to use AsyncCommand canExecuteChangedFactory? #26

RedX2501 opened this issue Dec 6, 2019 · 3 comments
Assignees

Comments

@RedX2501
Copy link

RedX2501 commented Dec 6, 2019

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: #11 (comment)

What is the expected way of using the factory in pre3 release?

@StephenCleary
Copy link
Owner

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

@RedX2501
Copy link
Author

RedX2501 commented Dec 7, 2019

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.

@SittenSpynne
Copy link

SittenSpynne commented Dec 16, 2019

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?

@StephenCleary StephenCleary self-assigned this Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants