What’s the difference between OnNavigatedTo and Loaded?

Sliding Block Puzzle was originally written to do all initialisation within the Loaded event handler for a page.  However, this yields some strange and unwanted behaviour sometimes, such as:

1. Pages don’t initialise properly when returning to them deactivation.

2. The Loaded event handler was being called twice when the VS2010 debugger is attached.

So, remember:

Loaded is called each time the page (or a control, if you’re in the handler for a control) is added to the “visual tree”, this means it may be called more than once.

OnNavigatedTo is called once only each time the page is activated.

Therefore, chances are, you want to be using OnNavigatedTo and not Loaded!

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.