Wednesday, May 11, 2011

ObservableDictionary for Silverlight

I just migrated Dr. WPF's ObservableDictionary for WPF to silverlight. You can find the code here :
https://bitbucket.org/basarat/dictionarybasedvm/overview . Also at the same location is a sample.

The basic objective of making this is that you can Make a View Model properties to be exposed via a Dictionary rather than a Model. I would have preferred to work with dynamic but couldn't as described here :  http://stackoverflow.com/q/5949826/390330 For change notification on bound string based indexer properties the dictionary needs to implement INotifyCollectionChanged. There is not dictionary on the framework that comes with this.

I will also be updating the project to try and implement IDataErrorInfo.

Application Screenshot :

Where the xaml is :

5 comments:

  1. How about NGenerics ObservableashList for Silverlight may be you can add IDataErrorInfo here.

    ReplyDelete
  2. Can't believe I'm the first to comment here. Nice post!
    I'm using this ObservableDictionary in my project

    ReplyDelete
  3. Thanks a lot for this.

    Being new to Silverlight and without a lot of experience in WPF I've spent the best part of this morning wondering what I was doing wrong, i.e. why was it working for an ObservableCollection but not for a dictionary. Should have consulted the oracle earlier.

    Thanks

    ReplyDelete
  4. Did you ever get to implement IDataErrorInfo? I'm having a difficult time with it since my view model only has one property and it's the ObservableDictionary.

    ReplyDelete