Files
modernkeepass/ModernKeePass/Common/NotifyPropertyChangedBase.cs
Geoffroy Bonneville 616d922145 New color to brush converter
New boolean to visibility converter
Base class to handle property changes notifications for all View Models
Template selector to handle a different first item in listviews or gridviews
2017-11-08 14:42:37 +01:00

29 lines
838 B
C#

using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace ModernKeePass.Common
{
public class NotifyPropertyChangedBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetProperty<T>(ref T property, T value, [CallerMemberName] string propertyName = "")
{
if (EqualityComparer<T>.Default.Equals(property, value))
{
return false;
}
property = value;
OnPropertyChanged(propertyName);
return true;
}
}
}