What Order Do Navigation Methods Get Called in Windows Phone?

by jason11. April 2011 07:34

Recently, I was asked which gets called first: the Application_Launching, Application_Activated, Application_Deactivated, and Application_Closing events or the page-specific OnNavigatedTo and OnNavigatedFrom overrides. It turns out, the answer is – both.

When the application first runs from the start screen, Application_Launching gets called first. Then, the page-specific OnNavigatedTo gets called.

When navigating back to the start screen (by pressing the start button), the page-specific OnNavigatedFrom override gets called and then the Application_Deactivated event gets fired.

When navigating back to the app (using the back button), the Application_Activated fires first, and then the page’s OnNavigatedTo override gets hit.

So, the rule of thumb seems to be, if you are on a page, that page’s overrides will be called first. If you are entering the app from elsewhere, the Application events will fire first. Now you (and I) know!

Tags: ,

Development | Windows Phone

About

Jason Williams is a .NET developer in Lincoln, Nebraska.

The name "Centrolutions" came out of a long search for a domain name. The goal was to create a name that conveyed an ideology of writing software centered (Centr--) on a solution (--olutions) for a particular problem. In other words, it was the only name in a long list that wasn't already registered on the internet.

If you're looking for the products I have for sale, you should go here.