You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
|
|
namespace ZeroLevel.WPF
|
|
|
|
|
{
|
|
|
|
|
public abstract class BaseViewModel
|
|
|
|
|
: INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
|
|
|
{
|
|
|
|
|
var handler = this.PropertyChanged;
|
|
|
|
|
if (null != handler)
|
|
|
|
|
{
|
|
|
|
|
this.VerifyPropertyName(propertyName);
|
|
|
|
|
var e = new PropertyChangedEventArgs(propertyName);
|
|
|
|
|
handler(this, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void VerifyPropertyName(string propertyName)
|
|
|
|
|
{
|
|
|
|
|
if (TypeDescriptor.GetProperties(this)[propertyName] == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("Invalid property name", propertyName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|