views:

33

answers:

1

Hi,

In a Windows Phone 7 app, the PhoneApplicationService.Current.State object is declared as an IDictionary, and is implemented as a Dictionary. I was really hoping to get notified when any state changes occur. (I realise I could build my own state collection somewhere else and do whatever I want, but I'm retrofitting this into existing code.)

Is there any way to get that State object set to an ObservableDictionary instead of a Dictionary, so I can attach to it and get notified when the collection changes?

I'm guessing the answer will be 'no' but just want to check I haven't missed something :)

Thanks,

John

A: 

You can't change the existing implementation, but you could create a wrapper class which implements IObservable but uses PhoneApplicationService.Current.State internally.
This way, you wouldn't have to build a complete state persistence soution yourself and could implement the ObservableDictionary as best meets your needs.

Matt Lacey
Cool, thanks. I thought there might be a clever way to swap it out, but wrapping around it sounds like the next best thing.
John