-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBindableBase.cs
More file actions
27 lines (21 loc) · 763 Bytes
/
Copy pathBindableBase.cs
File metadata and controls
27 lines (21 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace ObservableMvvm
{
public abstract class BindableBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
storage = value;
OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
return true;
}
protected void OnPropertyChanged(PropertyChangedEventArgs args)
{
PropertyChanged?.Invoke(this, args);
}
}
}