-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathBaseControl.cs
More file actions
27 lines (24 loc) · 855 Bytes
/
BaseControl.cs
File metadata and controls
27 lines (24 loc) · 855 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.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Controls;
namespace TensorStack.WPF.Controls
{
public class BaseControl : UserControl, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged([CallerMemberName] string property = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
}
protected bool SetProperty<T>(ref T field, T newValue, [CallerMemberName] string propertyName = null)
{
if (!Equals(field, newValue))
{
field = newValue;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
return true;
}
return false;
}
}
}