files

Code Snippets

Title: Basic INPC Support
Description: INotifyPropertyChanged as a basic sample.
Category: INPC
Visibility:  Public
Added by: ohanlonp on 5/6/2012

 Currently rated 4.67 by 3 user(s)

Get link for this code snippet
Collapse code snippet
Expand code snippet
Tweet this snippet
Tweet about this snippet
Delete code snippet
Edit code snippet
private event PropertyChangedEventHandler propertyChanged;

        /// <summary>
        /// Raises an event when a property has changed.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged
        {
            add { propertyChanged += value; }
            remove { propertyChanged -= value; }
        }

        /// <summary>
        /// Raise the <see cref="PropertyChanged"/> event.
        /// </summary>
        /// <param name="propertyName">The name of the property that changed.</param>
        protected virtual void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = propertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }