-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathObservableObject.cs
36 lines (31 loc) · 1.19 KB
/
ObservableObject.cs
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
28
29
30
31
32
33
34
35
36
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ObservableObject.cs" company="Helix Toolkit">
// Copyright (c) 2014 Helix Toolkit contributors
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace rpkg
{
using System.ComponentModel;
using System.Runtime.CompilerServices;
public abstract class ObservableObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName]string info = "")
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
protected bool SetValue<T>(ref T backingField, T value, [CallerMemberName]string propertyName = "")
{
if (object.Equals(backingField, value))
{
return false;
}
backingField = value;
this.OnPropertyChanged(propertyName);
return true;
}
}
}