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.
Zero/WPFExamples/BaseViewModel.cs

31 lines
851 B

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);
}
}
}
}

Powered by TurnKey Linux.