I have a page in my WP7 which contains some text boxes. When pressing the back key this method is run to save the contents:
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
var settings = IsolatedStorageSettings.ApplicationSettings;
settings["remZone"] = txtBoxZone.Text;
settings["remSpace"] = txtBoxSpace.Text;
}
The problem is some users would not press the back button, but would press the home button to exit the app, so the contents are not saved.
I think there are two avenues round this if possible:
1. Is there a function that would run this method when the home button is pressed, like the onBackKeyPress.
2. Is there a simple way to save the contents of the text box as the user is entering it?
Thanks.
EDIT:
solution was this:
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
var settings = IsolatedStorageSettings.ApplicationSettings;
settings["remZone"] = txtBoxZone.Text;
settings["remSpace"] = txtBoxSpace.Text;
}
The simplest solution to your problem would be overriding
Page.OnNavigatingFrommethod.more here