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

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

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