Raise Can Execute Changed method when each interested property changes (lines 9-10 and 20-21), so that the system will call the Can Execute handler and determine the new execution state of the command.
Even in this simple example, we can see that, if a command depends on several properties, it is necessary to call the Raise Can Execute Changed method every time one of them chages. To simplify our apps, we can leverage the Messenger object that comes with MVVM Light. Set method has an overload that allows to broadcast a Property Changed Message notification using the Messenger if the corresponding property actually changes.
When this happens you may have to manually force this refresh to occur.
Hello, I only want that my update button is active if entries are edited AND it's not the first load.
When i go on my page, data is loaded in entries and Is Edited switch to True, result my update button is active.
In the Initialize method (lines 17-24), we use the Messenger to register for the Property Changed Message Base notification.
When such a message is received, we determine whether the changed property is contained in the list of the monitored ones.
Unfortunately, there is no Command Manager in PCL (portable class library).
When using commands, usually in an MVVM scenario, we can define a method, Can Execute, that determines whether a command can execute in its current state.If so, we call the Raise Can Execute Changed method, which in turns forces the system to invoke the Can Execute handler.Now we can update the Main View Model to use this new command type: argument of the Set method.This last call is what tells controls that are bound to commands to check their “can execute” status.WPF is the only XAML framework that uses the Command Manager to automagically raise the Can Execute Changed event on ICommands.Also, I up-voted your answer immediately, then took the vote back to see whether it worked. Thanks @Arcturus Just an FYI I commented out Command Manager.