28 lines
863 B
C#
28 lines
863 B
C#
|
|
namespace Utils.Basis
|
|||
|
|
{
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
|
|||
|
|
public abstract class ViewModelBase : INotifyPropertyChanged
|
|||
|
|
{
|
|||
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|||
|
|
|
|||
|
|
protected bool Set<T>(ref T field, T newValue = default(T), [System.Runtime.CompilerServices.CallerMemberName] string propertyName = null)
|
|||
|
|
{
|
|||
|
|
if (System.Collections.Generic.EqualityComparer<T>.Default.Equals(field, newValue))
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
field = newValue;
|
|||
|
|
|
|||
|
|
OnPropertyChanged(propertyName);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public virtual void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null)
|
|||
|
|
{
|
|||
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|