If I lock my phone while running my application and unlock it say after 30 minutes or 60 minutes, my screen appears blank. All my data (its a huge list compare it to a user's twitter feed) which was in an Observable collection
in my ViewModel
has disappeared. When I refresh I get NullReferenceException
. Note that I am not handling any state save
while locking and unlocking the phone. Is that the reason for the loss of my data? How can I handle it? Since there is a limit on the state data which can be saved of 4Mb Max, will it affect the functioning of my application even if I do implement it?
[Update]
I have tried the following things:
1) http://www.scottlogic.co.uk/blog/colin/2011/05/a-simple-windows-phone-7-mvvm-tombstoning-example/
2) http://www.scottlogic.co.uk/blog/colin/2011/10/a-windows-phone-7-1-mango-mvvm-tombstoning-example/
and many more.
The problem which I now face is that my application's viewModel contains an observable collection
which I have binded to the UI. This observable collection is a collection of my user-defined class which contains complex data members
. One of them is a dictionary
. When i try to save my viewModel using XMLSerialization
it throws an error as XML serialization doesn't support Dictionary.
I have also tried to write my viewmodel after Data contract serialization
onto the IS during App_Deactivated and retrieve it on App_Activated. But my collection is null on resume. On opening the IS file it shows that the collection was not written onto the file. Am I missing some key ingredient
in-order to solve this problem?
Note: I need my list. I cannot refresh data.