none
Best Approach to Caching Data

    Question

  • I'd like to get data for my dropdown controls once when the application starts and save it for reuse on future page visits. This is pretty static data. In ASP.NET I'd store this in the Application object. Should this go in Isolated Storage? I'm already using it for application settings, but the default limit is 1MB.

    I'm sure someone has already solved this, but I haven't found a solution.

    Thursday, April 26, 2012 3:22 PM

Answers

  • Hi,

    For silverlight is a plugin, so you can create a static class for saving information.

    To share some value between pages, you can use the code below into App.xaml.cs:

    private static Dictionary<string, object> session = new Dictionary<string, object>();        
            public static Dictionary<string, object> Session        
            {            
                get { return session; }            
                set { session = value; }        
            }

    Then anywhere you can use the below:

    App.Session["Empty"] = string.Empty;

    For ObservableCollection, please refer to the link below:

    http://stackoverflow.com/questions/5073925/problem-storing-a-list-of-objects-in-isolated-storage

    Hope helpful.

    Monday, April 30, 2012 1:19 AM

All replies

  • I tried storing the data (observable collection of entities) directly in Isolated Storage, but that fails due to a serialization issue. MSDN says entities generated by the framework are serializable, but apparently the collection is not.

    Friday, April 27, 2012 1:06 PM
  • Hi,

    For silverlight is a plugin, so you can create a static class for saving information.

    To share some value between pages, you can use the code below into App.xaml.cs:

    private static Dictionary<string, object> session = new Dictionary<string, object>();        
            public static Dictionary<string, object> Session        
            {            
                get { return session; }            
                set { session = value; }        
            }

    Then anywhere you can use the below:

    App.Session["Empty"] = string.Empty;

    For ObservableCollection, please refer to the link below:

    http://stackoverflow.com/questions/5073925/problem-storing-a-list-of-objects-in-isolated-storage

    Hope helpful.

    Monday, April 30, 2012 1:19 AM
  • Thanks Otomii. Having access anywhere is great and I assume access to anyone applies as well. This link may also be very helpful. I'll mark your response as the answer if it works.

    Monday, April 30, 2012 7:13 AM