Reduce Ambiguity in MVVM (Full) CommandBinding #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First time using github / proposing changes so apologies if wrong process followed here.
Summary of proposed change (also hopefully documented in specific commits):
Changes should update MVVM example to update ICommandBinding and CommandBinding classes to remove the Context object parameter input to "EvaluateCanExecute" in the ICommandBinding interface.
Couple reasons to remove the Context input to EvaluateCanExcute
The current interface requires a caller/user of the interface to know the Context the CommandBinding is going to 'auto-execute' the Command in (e.g. to be carrying around a copy of ViewModel since the current implementation of CommandBinding will only execute in that stored context) in order to use ICommandBinding.EvaluateCanExecute.
Anything that will want to evaluate the command's canexecute in a alternate specific context can still access the command's can execute through the Command property on the ICommand interface -
As an alternative, one could change the signature for EvaluateCanExecute to EvaluateCanExecute(Optional Context as object). This would have advantage of not making it a breaking change... but this would still leave an ambiguity/confusion between the interface and the specific implementation provided as an example - and it seems to me as this is provided as a teaching example / potential framework, the purpose of a CommandBinding is to encapsulate all of the dependencies on the linkage and so should be independent of evaluating the Command in arbitrary contexts.
Above offered in light of reading about MVVM-lite and hopefully is helpful