using System.ComponentModel; using System; using System.Windows.Input; namespace starter.viewmodel.common { public abstract class NotificationObject : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; ///< summary> /// announce notification /// ///< param name="propertyName">property name public void RaisePropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } ///< summary> /// BaseCommand /// public class BaseCommand : ICommand { private Func _canExecute; private Action _execute; public BaseCommand(Func canExecute, Action execute) { _canExecute = canExecute; _execute = execute; } public BaseCommand(Action execute) : this(null, execute) { } public event EventHandler CanExecuteChanged { add { if (_canExecute != null) { CommandManager.RequerySuggested += value; } } remove { if (_canExecute != null) { CommandManager.RequerySuggested -= value; } } } public bool CanExecute(object parameter) { return _canExecute == null ? true : _canExecute(parameter); } public void Execute(object parameter) { if (_execute != null && CanExecute(parameter)) { _execute(parameter); } } } }