// use this when the command is owned by the source object - i.e. we aren't concerned about their relative lifespans public static perCommandBase ObservesInternalProperty(this perCommandBase command, INotifyPropertyChanged source, string propertyName) { source.PropertyChanged += (s, e) => { if (string.Equals(e.PropertyName, propertyName, StringComparison.InvariantCultureIgnoreCase)) { command.RaiseCanExecuteChanged(); } }; return(command); }
public static perCommandBase ObservesCollection(this perCommandBase command, INotifyCollectionChanged collection) { collection.CollectionChanged += (s, e) => command.RaiseCanExecuteChanged(); return(command); }