Windows Phone 7: Saving data - Persistant storage
So now we have our application page data bound we can save the actual data using our application's store.
Within our page's xaml.cs we'll have a save function that'll be called by clicking a save button. Function will contain:
So you can see here how we can easily save the data in our application's store. Retrieving this is a little trickier, however. My example will be cautious, perhaps overly so. Within the Application_Launching event we'll add this code, which looks for our saved data and retrieves it then binds it to our page.
As you can see I frequently check that the data we're retrieving is what we're expecting. If the file doesn't exist we bind it to an fresh class to allow for saving. Provided that our data bindings are correct we can re-save/load with ease.
Within our page's xaml.cs we'll have a save function that'll be called by clicking a save button. Function will contain:
So you can see here how we can easily save the data in our application's store. Retrieving this is a little trickier, however. My example will be cautious, perhaps overly so. Within the Application_Launching event we'll add this code, which looks for our saved data and retrieves it then binds it to our page.
As you can see I frequently check that the data we're retrieving is what we're expecting. If the file doesn't exist we bind it to an fresh class to allow for saving. Provided that our data bindings are correct we can re-save/load with ease.