using System; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; namespace NotificationFlyoutSample { public class ObservableObject : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public virtual void OnPropertyChanged([CallerMemberName] string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); protected virtual bool SetProperty(ref T backingStore, T value, [CallerMemberName] string propertyName = "", Action onChanged = null, Func validateValue = null) { if (EqualityComparer.Default.Equals(backingStore, value)) return false; if (validateValue != null && !validateValue(backingStore, value)) return false; backingStore = value; onChanged?.Invoke(); OnPropertyChanged(propertyName); return true; } } }