OnNavigatedTo mysteriously not firing on Windows P

2019-09-02 05:35发布

问题:

I am trying to handle state restoration on a sub-page of my app. I've hooked the OnNavigatedFrom and OnNavigatedTo overrides in order to do this. However - although they fire quite happily while I am navigating around the app itself, the OnNavigatedTo does not fire when I switch out of the app with that page active, then try to reactivate it. This is made all the more mysterious because another near-identical app I have seems to work fine.

Is there some sort of setting somewhere that might prevent OnNavigatedTo from firing when my app comes back from tombstoning, but allows it to fire when the user navigates around screens in my app?

Chris

回答1:

If you're going back almost immediately, it may be possible that your app is still running the same as it was, but the OnNavigatedTo should still be fired even in that case (more recent info: link text).

Are you doing anything fancy in your constructors, such as hooking up event handlers to try and handle the state changes from the frame?

If so, drop that and see where it gets you, ctors should be mostly empty.