How to Raize Command to evalituate in mvvm
- In mvvmlight, we bind our control to the relaycommand object. But, the commmand only execute the CanExecute() onetime, if some specifies changed, how could we notify the control to re-evaluate. Im mvvm light, we can find, two elements in RelayCommand: event CanExecuteChanged, RaiseCanExecuteChagned(), so we can add our customized event handles to the event, and we can call the RaiseCanExecuteChanged() function to raise the event,
Sample code:
public int Index { get { return _index; } set { _index = value; RaisePropertyChanged(""); ((RelayCommand)BackCommand).RaiseCanExecuteChanged(); ((RelayCommand )NextCommand).RaiseCanExecuteChanged(); } }