Click here to Skip to main content
15,896,502 members
Articles / Desktop Programming / WPF

Working with ObservableCollection<T>

Rate me:
Please Sign up or sign in to vote.
4.56/5 (25 votes)
17 Dec 2009CPOL3 min read 139.2K   3.3K   51  
One of the most useful classes when working with WPF can be found in the System.ComponentModel namespace, namely the ObservableCollection
using System.ComponentModel;

namespace ViewableCollectionDemo.ViewModels.ObjectModel
{
    /// <summary>
    /// This class is the base class for all ViewModel classes.
    /// </summary>
    public class ObservableObject : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Helper method to raise the PropertyChanged event.
        /// </summary>
        /// <param name="PropertyName">The name of the property that has been changed, as a string.</param>
        protected void RaisePropertyChanged(string PropertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer N/A
Canada Canada
Sanjay was weaned on VB6, then was dragged kicking and screaming into the world of .NET development, with VB.NET. He was pleasantly surprised, and quickly migrated existing projects to reap the benefits of the massive .NET libraries.

Quite a while ago, he started a pet project that involved fading in and out controls (as well as other animations) in a Windows Forms application. After weeks of hard work, he finally realized that there had to be a better way.

He found WPF.

He changed his main programming language to C#, and has never looked back.

Comments and Discussions