As well as being used for the "Can Execute" delegate, it's also bound to the Is Enabled property of a few controls in the view to enable/disable them).
When I click my "Start" button (bound to 'Start Command'), the "Save" button is correctly disabled.
This code works mostly correct but i can not make method Can Save Item to work properly.
Event Args) 'This is the Raise Event block 'Command Manager. Invoke End If End Function Public Sub Execute(By Val parameter As Object) Implements System. However, if your command is completed asynchronously (think background worker or similar with an oncompleted event) the oncompleted handle needs to update the appropriate data that the command relies on, then call the Raise Can Execute Changed event on the command.
New(execute, Nothing) End Sub Public Sub New(By Val execute As Action, By Val can Execute As Func(Of Boolean)) If execute Is Nothing Then Throw New Argument Null Exception("execute") End If _Execute = execute _Can Execute = can Execute End Sub #End Region #Region "ICommand" Public Custom Event Can Execute Changed As Event Handler Implements System. Requery Suggested, value End If End Remove Handler Raise Event(By Val sender As Object, By Val e As System. Can Execute If _Can Execute Is Nothing Then Return True Else Return _Can Execute. WPF will use any local change to requery commands states, so, for example, if you click a button, or click the form, or if the change of the command state occurs as a result of a button click for example, this change will show without manually needing to prod the command.
I don't know how to tell to Save Command that properties of View Model was changed.
I know that i have to use Can Execute Changed or Command Manager. Perhaps I am misunderstanding this, but if you don't want to command to execute until a value changes in your entities, why not add an "Is Dirty" field to your entities?
The b/g process runs to completion, then Is Running is set to false, but this doesn't trigger the "Save" button to become enabled. (The controls whose property to 'Is Running', but it's frustrating that this particular view refused to play ball. Common sense says it's something specific to this view/VM, but I'm stumped (and I'm not going to post the code here - there's too much of it).