Page Loaded Method etc

Just move the cursor in the .xaml file to before the Grid, then in the right properties select events and double click on the one you want to add (e.g. ‘Loaded’ for page loaded)

Built In Methods when using the Frame navigation system of the main window with Pages

OnNavigationFrom is invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame.

		//*************************************************************
		//*************************************************************
		//********** PAGE ABOUT TO BE SOURCE OF PARENT FRAME **********
		//*************************************************************
		//*************************************************************
		protected override void OnNavigatedTo(NavigationEventArgs e)
		{

		}
		//***********************************************************************
	//***********************************************************************
		//********** PAGE ABOUT TO NO LONGER BE SOURCE OF PARENT FRAME **********
		//***********************************************************************
		//***********************************************************************
		protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
		{

		}
Some typical methods to use
Loaded (call it say Page_Loaded)

This is the event to use as a page is about to display, it will always be called.

The alternative OnNavigated event is called when page navigation is done, but before(during) page controls are loaded, while Loaded is called when page is ready and all controls are loaded.

The Loaded event will always fire after OnNavigatedTo (even when pages are being cached by setting NavigationCacheMode.Required).

	//********************************************
	//********************************************
	//********** PAGE ABOUT TO BE SHOWN **********
	//********************************************
	//********************************************
	private void Page_Loaded(object sender, RoutedEventArgs e)		//<<<<Create event from .xaml event handlers!
	{

	}
Unloaded (call is say Page_Unloaded)
	//************************************************
	//************************************************
	//********** PAGE NO LONGER BEING SHOWN **********
	//************************************************
	//************************************************
	private void Page_Unloaded(object sender, RoutedEventArgs e)		//<<<<Create event from .xaml event handlers!
	{

	}
GotFocus & LostFocus

These are no use for page appears/gone they are simply the page background and get triggered when page controls get focus and loose focus

UK Electronic Designer
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.