I normally override RaisePropertyChanged and set my CanExecute predicate to whether the ViewModel is dirty or not.
class ViewModel : ViewModelBase
{
public DelegateCommand SaveCommand { get; set; }
private bool _isDirty;
public ViewModel()
{
SaveCommand = new DelegateCommand(() => OnExecuteSave(), () => CanExecuteSave());
}
private void CanExecuteSave()
{
// do your saving
}
private bool CanExecuteSave()
{
return !_isDirty;
}
protected override void RaisePropertyChanged(string propertyName)
{
base.RaisePropertyChanged(propertyName);
_isDirty == true;
SaveCommand.RaiseCanExecuteChanged();
}
}
Hope that helps.