I'm migrating a tool from MVVM Light 4.0.3 to 5.4.1 and I have found a very odd issue with the newest RelayCommand implementation.
This is the old implementation in the V4.0.3:
This is the newest implementation in the V5.4.1:
Before I was able to use variables to define the canExecute behaviour (enabled a button) with the following code:
public ICommand GetNewItemsFromDB { get; private set; }
private bool _IsActive;
public bool IsActive
{
get
{
return _IsActive;
}
set
{
if (_IsActive != value)
{
_IsActive = value;
this.RaisePropertyChanged(() => IsActive);
}
}
}
GetNewItemsFromDB = new RelayCommand(GetDataFromDB, () => { return IsActive == false; });
private void GetDataFromDB()
{
IsActive = true;
}
The previous code was able to enable the button without any issue in the MVVM Light 4.0.3; however, in the newest implementation is always disabled, I added changed a bit since there is a new definition of keepTargetAlive:
GetNewItemsFromDB = new RelayCommand(GetDataFromDB, () => { return IsActive == false; }, true);
Also, I tried the false option and nothing changed. The only way that I found to re-enabled it, it was to set a predefined value like this one:
GetNewItemsFromDB = new RelayCommand(GetDataFromDB, () => true, true);
This implementation is going to be useless in my case since the RelayCommand depends on the variable IsActive, which determines if it's enabled or not. Does anyone what I should change in the V5 to make it work? Thanks for your suggestions.



