Reputation: 1191
I do some clean up stuff in my PhoneApplicationUnloaded event on a xaml page. If I put a breakpoint inside the event, I can see that it gets hit if I use the backbutton to unload the page, or if I navigate forward anywhere, but if I use the start button to go back to the home screen, I don't see the breakpoint get hit.
Does this event really get called when you hit the start button? (maybe for some reason the emulator stops debugging when that happens and I don't see it get hit) or does it not. And if it doesn't what event should instead?
Upvotes: 0
Views: 191
Reputation: 6862
There's a good article on MSDN that explains what happens when Start button is pressed and which event you should bind to. Whenever the application gets interrupted (like by a phone call or start button), it gets tombstoned, and the associated Application_Deactivated event is raised. Whenever the focus gets back to your application, you get Application_Activated event (where you're supposed to restore previous state).
Upvotes: 2
Reputation: 7539
Hitting the start button doesn't unload the application, the other scenarios do unload the application. Put the code in your Unload event into a common class that both the Unload event and the button click event can call.
Upvotes: 0