Eventos de navegación cuando la aplicación pasa a segundo plano

Whenever I am putting my application into background, or calling a chooser task, the NavigateFrom and (when comming back) the NavigateTo events fire.

How can I tell when are we actually navigating somewhere, or when is the application going into background?

preguntado el 03 de mayo de 12 a las 13:05

Have you looked into the Activated and Deactivated events in the App.xaml.cs? -

I have to get the first page from the backstack, on every page (except when leaving the application) and save it to a dictionary, Activate and Deactivate doesn't really help in this case -

1 Respuestas

if your app starts the OnNavigatedTo NavigationEventArgs NavigationMode is new, if your app comes back from tombstoning the OnNavigatedTo NavigationMode is back, if you set a boolean in App.xaml in the activated event and check if this boolean is set you can determine if your application is comming back from tombstoning. in the OnNavigatedFrom on tombstoning the NavigationEventArgs NavigationMode is new, while if you press the back button the NavigationMode is back, I'm not sure if any other state can occur for OnNavigatedFrom. So if OnNavigatedFrom NavigationMode is new I'm guessing your app is tombstoning

contestado el 03 de mayo de 12 a las 14:05

I just found a more simple answer to my question: e.IsNavigationInitiator == true simple navigation e.IsNavigationInitiator == false navigating to background - Igor Meszaros

I also looked into IsNavigationInitiator, but on the emulator, It's always returning false, so I'm not sure it's a working solution - pieter_dv

I've implemented it and tested it on my phone and it works as I see, don't want to start an emulator now, because it kills my pc - Igor Meszaros

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.