Implementing INotifyPropertyChanged: The Traditional Approach
The INotifyPropertyChanged
interface has a single event called PropertyChanged
. The implementation of INotifyPropertyChanged
ordinarily includes the following construct:
public event PropertyChangedEventHandler PropertyChanged;protected virtual void OnPropertyChanged( [CallerMemberName] string propertyName = null){ PropertyChangedEventHandler tempEvent = PropertyChanged; if (tempEvent != null) { tempEvent(this, new PropertyChangedEventArgs(propertyName)); }}
The CallerMemberName
attribute is used by a new compiler feature that automatically passes the name of the calling member to the target method. No longer is it necessary in ...
Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.