You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LivreLand/PersonalMVVMToolkit/ObservableObject.cs

38 lines
1.2 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace PersonalMVVMToolkit
{
public class ObservableObject : INotifyPropertyChanged
{
#region Properties
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string PropertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName));
protected virtual void SetProperty<T>(T member, T value, Action<T> action, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(member, value)) return;
action(value);
OnPropertyChanged(propertyName);
}
protected virtual void SetProperty<T>(ref T member, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(member, value)) return;
member = value;
OnPropertyChanged(propertyName);
}
#endregion
}
}