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

InvokeCommandAction - add additional properties for more MVVM scenarios #12

Closed
brianlagunas opened this issue Dec 11, 2018 · 7 comments
Closed
Assignees

Comments

@brianlagunas
Copy link
Collaborator

I would like to suggest we add some additional properties to the InvokeCommandAction to make it more useful in WPF applications using the MVVM pattern.

Suggested properties:

  • EventArgsParameterPath - a path to extract a property value from the EventArgs instance to pass to the ICommand as the command parameter.
  • EventArgsConverter - a converter to convert the event args to a more friendly type meant for ViewModel consumption.
  • EventArgsConverterParameter - an argument passed as parameter to the EventArgsConverter that can be used to make more complex decisions.

Thoughts?

@brianlagunas brianlagunas self-assigned this Dec 11, 2018
@Gergilcan
Copy link

I think it is a good idea but instead of eventargsparameterPath i would like to have a DisplayMemberPath in order to be able to select a property value fron the event args OR the result of the converter(post-evaluated)

@brianlagunas
Copy link
Collaborator Author

brianlagunas commented Dec 11, 2018

DisplayMemberPath has a different meaning in WPF and does not apply to this concept. If anything, ValueMemberPath would be closer, however it is still not clear exactly what that name does in the context of the InvokeCommandAction behavior. However, I am not against an EventArgsMemberPath or EventArgsValueMemberPath. Also, applying the parameter path tot he return result of a converter doesn't make sense. You are explicitly opting into using a converter, no need to add additional complexity to the result of that converter.

@nigel-sampson
Copy link
Collaborator

Agree for the converter params, am always a little worried about Path / reflection based properties. But can see how it would be useful. As long as all three play well together. Would ParameterPath affect the value passed to the converter?

@brianlagunas
Copy link
Collaborator Author

brianlagunas commented Dec 11, 2018

No. The parameters path takes precedent over the EventArgsConverter. If the EventArgsParametrPath is not set, then the EventArgsConverter would be used (only if PassEventArgsToCommand was set to true).

The order of operations is as follow:

  • CommandParameter
  • EventArgsParameterPath
  • EventArgsConverter (if PassEventArgsToCommand = true)

@brianlagunas
Copy link
Collaborator Author

I was almost thinking that PassEventArgsToCommand would only control if the actual EventArgs are passed as a parameter since that is a major MVVM "no-no". If an EventArgsConverter was found then use it regardless of the PassEventArgsToCommand property.

@brianlagunas
Copy link
Collaborator Author

Fixed with PR #14

@usernamedd
Copy link

why isnot there a sample about PassEventArgsToCommand

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

4 participants