Strongly typed NotifyPropertyChanged using Reflection
While my version is not as pretty when used, The implementation of it is much shorter.
public class PropertyChangedBase : INotifyPropertyChanged
{
private string GetName<T>(T item) where T : class
{
var properties = typeof(T).GetProperties();
return properties[0].Name;
}
}
Usage:
public class SomeViewModel : PropertyChangedBase
{
string name;
public string Name
{
get { return name; }
set
{
name = value;
NotifyOfPropertyChange(GetName(new {Name}));
}
}
}
Fork
0 Feedback
You must log in before you can give any feedback
You must log in before you can post a comment