how would I access the data from the current page?
First of all extending the solution suggested by Richard if you still wondering about accessing data.
private void Application_Deactivated(object sender, DeactivatedEventArgs e) |
{ |
PhoneApplicationPage page = (App.Current.RootVisual as PhoneApplicationFrame).Content as PhoneApplicationPage; |
if (page is MainPage) |
{ |
MainPage mainPage = (MainPage)page; |
|
//testData is a public variable defined in your MainPage |
int data = mainPage.testData; //This is to demonstrate how to acess data |
} |
} |
Other possible solution (holds good, if small amount of data) would be defining a global variable in App.xaml file and update that variable on MainPage.cs then at the time of deactivation use that variable to save data. But I would still suggest to use
first method. Rest depends what you can implement more conveniently in your app :-)
Thanks and Regards
Nishant Rana