I am using MVVM-Light RelayCommand
private ICommand myRevertCmd;
public ICommand Revert
    {
        get
        {
            if (myRevertCmd == null)
            {
                myRevertCmd = new RelayCommand(RevertExecute, CanRevertExecute);
            }
            return myRevertCmd;
        }
    }
    private void RevertExecute()
    {
        searchType = SearchType.Revert;
        SearchStart();
    }
    private bool CanRevertExecute()
    {
        return isRevertEnabled;
    }
I have some code that changes the value of isRevertEnabled but the linked button does not change. After some searching I found that you can use to force the re-evaluation of the button states
// force the GUI to re-evaluate the state of the buttons
CommandManager.InvalidateRequerySuggested();
But this doesn't work. Does any one have any suggestions?
Just to add another possible solution, in my case I needed to call CommandManager.InvalidateRequerySuggested on the UI thread using Application.Current.Dispatcher.Invoke.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With