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

CommandParameter evaluates CanExecute #3452

Closed
vsfeedback opened this issue Sep 4, 2020 · 4 comments
Closed

CommandParameter evaluates CanExecute #3452

vsfeedback opened this issue Sep 4, 2020 · 4 comments
Labels
API suggestion Early API idea and discussion, it is NOT ready for implementation

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


Behavior concerning ButtonBase-Class:

Currently, only the ValueChangedCallback from the CommandProperty invokes the CanExecute-Method of the given Command. It would be highly useful, if also the ValueChangedCallback of the CommandParameterProperty would invoke CanExecute on the Command (if not null).


Original Comments

Fiona Niu[MSFT] on 10/19/2018, 05:51 PM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. You will hear from us in about a week on our next steps.

@ryalanms ryalanms added the API suggestion Early API idea and discussion, it is NOT ready for implementation label Sep 14, 2020
@peterduniho
Copy link

peterduniho commented Dec 6, 2020

Please note that this issue exists also with the MenuItem class. I haven't checked, but this probably also applies to the InputBinding class, and possibly any other class that has a pair of Command and CommandParameter dependency properties (e.g. ThumbButtonInfo, Hyperlink, etc.)

I'm not entirely clear on the relationship between CommandManager and various WPF types that implement this property pair, but it seems like this issue and https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3571 are related to each other, if not actually duplicates. The main complaint on that issue is that the CommandManager doesn't respond to changes to bound CommandParameter values and call CanExecute() in response.

My expectation is that in both scenarios, when the source of a bound CommandParameter value changes, the associated ICommand.CanExecute() method will be called with the new parameter value, and (where applicable) the state of the element owning the bound property will be updated accordingly (i.e. disabled if CanExecute() returns false, enabled if it returns true).

@SetTrend
Copy link

SetTrend commented Feb 22, 2021

When implementing a solution to this issue, may I humbly suggest to DRY and extract/implement all command related code into a separate CommandHandler class.

This issue seems related to #316.

@olejorgensen
Copy link

I hate this issue so much. It has been broken forever

@pchaurasia14
Copy link
Member

Closing as the completed since the corresponding PR has been merged and released.

@ghost ghost removed this from the Future milestone Aug 30, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API suggestion Early API idea and discussion, it is NOT ready for implementation
Projects
None yet
Development

No branches or pull requests

6 participants