To navigate to a newest page, we can use the Navigate() method from the frame.
contentRoot.Navigate(typeof(MyPage), parameter);
where contentRoot
is the Frame instance and MyPage
a control inheriting from Page
In MyPage
, the OnNavigatedTo() method will be called once the navigation will complete (ie when the user will enter the page) allowing us to triggering or finalizing the loading of the page data. The OnNavigatedFrom() method will be called when leaving the page allowing us to release what has to be released.
public class MyPage : Page
{
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// the page is now the current page of the application. We can finalized the loading of the data to display
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
// our page will be removed from the screen, we release what has to be released
}
}