views:

20

answers:

1

Hi,

In Silverlight, How can we persist data between different pages and controls. In our application, we plan to have central data object which is to track the user changes from different pages and controls.

How many ways can we have to achieve this? And What's your recommended one?

Thanks, aghein.ng

+1  A: 

Like you mention, you could use an application level (global) data object - implement it as a singleton and it will be available to all pages/controls. With this you can add properties to the global object and track state with it. You may encounter issues if you have multiple threads accessing the same property at the same time, either work out a synchronization method or avoid situations where two threads could compete to set the same value.

Another possible option is to use IsolatedStorage. This is more of a data store but is very useful for keeping data between different runs of your application (i.e. you can save stuff into it for use when the user shuts down your app and then runs it the next day).

slugster
Thanks slugster. So do you prefer to use IsolatedStorage?
aghein.ng
@aghein - IsolatedStorage could be perfect for what you need, just be aware of a few things, like disk space restrictions, and more complicated objects may need to be serializable.
slugster
Thanks slugster.
aghein.ng