0
votes

Has anyone seen Laurent Bugnion's great demo at MIX10? If you are into MVVM-light I would call it a must see, I do have a question that I can't see to figure out... In the demo that uses RelayCommand, he does two examples - one where we implement Icommand itself and one where use RelayCommand from MVVM Light. On the second example he specifically says that you need to call RaiseCanExecuteChanged in the on the SayHello command when the Counter property changes. but I commented this out and it works...

Sorry - you have to be familiar with the demo to get this question but I hope someone might be... I also hope someone can clear this up - I don't seem to know why we need to do what he is talking about cause it works just fine otherwise.

Thanks!!!

1

1 Answers

0
votes

I can't speak to the specific internal wiring that drives this, so take my comments with that in mind.

I believe that data binding will routinely (and sometimes intelligently) requery the CanExecute method of ICommand. Calling RaiseCanExecuteChanged is a way of ensuring that button will requery it as soon as possible.

If anyone else can explain when buttons decide when to requery, I'd love to know that too.