Click here to Skip to main content
Click here to Skip to main content

ObservableDictionary!

, 22 May 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

John Simmons / outlaw programmer
Software Developer (Senior)
United States United States
I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.
 
My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.

Comments and Discussions

 
GeneralI just posted an alternative as part of the solution to anot... PinmemberJohn Stewien8-Jun-11 13:51 
GeneralAwesome. I googled ObservableDictionary and the Dr. WPF link... PinmemberSledgeHammer0122-May-10 14:32 
GeneralYou might want to check out the Reactive Extensions for .Net... PinstaffMatthew Dennis22-May-10 14:30 
You might want to check out the Reactive Extensions for .Net (or JavaScript). Any IEnumerable can be turned into an Observable collection. See http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx.
There are also a number of Blogs about it. Also Channel9 has several videos.
GeneralReason for my vote of "5". To offset the univoting schmuck. PinmemberWes Aday22-May-10 14:12 
GeneralI beg to differ. I needed an observable dictionary, and I am... PinmvpJohn Simmons / outlaw programmer22-May-10 9:43 
GeneralReason for my vote of 1 links are not tips PinmemberSledgeHammer0122-May-10 9:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411028.1 | Last Updated 22 May 2010
Article Copyright 2010 by John Simmons / outlaw programmer
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid