I am having yet another problem with my application for my phone.
My problem is the following:
On one page I have a list of pictures, and a button marked as "favorite." If you are to favorite the particular image of the row, the border of the image changes colors to signify this.
However, whenever I tombstone my application or hit the back button and go back to that very same page, the borders of the images are back to their default color.
Now before you ask, I have no idea if this is an isolated memory problem. I have just begun looking into Isolated storage, and it's difficult for me to grasp at the moment.
Maybe this is a saving state problem?
Either way, I would like to have my application remember what the favorites are whenever a user exits the application or tombstones it,开发者_运维技巧 or hits the back button, etc.
Could someone please provide a piece of code in order to help with this?
You need to save your data because the system is basically killing your app. So you need in your app.xaml.cs write code to save and read your data in metods:
// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
}
// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
}
精彩评论