Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WPF

ObservableDictionary!

4.95/5 (7 votes)
22 May 2010CPOL1 min read 47.3K  
In WPF/Silverlight, you might want to bind to a dictionary. Here's a couple of websites I found.
I was writing some code today, and decided it would be real nice if I could use an ObservableDictionary to allow the possible binding of items to a WPF/Silverlight control. Of course, I was dismayed to find that Microsoft (once again) failed to anticipate the needs of (quite possibly) the laziest programmer ever to stop around in Visual Studio - there was no such collection in .Net. Lookout google, here I come.

I was pleased my search was a relatively short one, and in the interest of saving you the time of conducting an identical search, I present you with my results - a sort of one-stop shopping experience, if you will.

The first link provides the article discussing the basic ObservableDictionary:

http://drwpf.com/blog/2007/09/16/can-i-bind-my-itemscontrol-to-a-dictionary/[^]

And the second link allows you to add XML serialization:

http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx[^]

As with anything on the internet, I don't know how long these things will be around, so if I were you, I'd scoop the code as soon as humanly possible. I'[m working on an article that actually uses some of this code, so eventually, you'll be able to get it here as well (I'll get the original authors' permissions before I do that, though).

License

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