{"id":203,"date":"2016-12-01T22:23:48","date_gmt":"2016-12-01T22:23:48","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=203"},"modified":"2016-12-01T22:23:48","modified_gmt":"2016-12-01T22:23:48","slug":"page-methods","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/windows-and-pages\/pages\/page-methods","title":{"rendered":"Page Methods"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Page Loaded Method etc<\/h4>\n\n\n\n<p>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. &#8216;Loaded&#8217; for page loaded)<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Built In Methods when using the Frame navigation system of the main window with Pages<\/h5>\n\n\n\n<p>OnNavigationFrom is invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\t\/\/*************************************************************\n\t\t\/\/*************************************************************\n\t\t\/\/********** PAGE ABOUT TO BE SOURCE OF PARENT FRAME **********\n\t\t\/\/*************************************************************\n\t\t\/\/*************************************************************\n\t\tprotected override void OnNavigatedTo(NavigationEventArgs e)\n\t\t{\n\n\t\t}\n\t\t\/\/***********************************************************************\n\t\/\/***********************************************************************\n\t\t\/\/********** PAGE ABOUT TO NO LONGER BE SOURCE OF PARENT FRAME **********\n\t\t\/\/***********************************************************************\n\t\t\/\/***********************************************************************\n\t\tprotected override void OnNavigatingFrom(NavigatingCancelEventArgs e)\n\t\t{\n\n\t\t}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Some typical methods to use<\/h5>\n\n\n\n<h5 class=\"wp-block-heading\">Loaded (call it say Page_Loaded)<\/h5>\n\n\n\n<p>This is the event to use as a page is about to display, it will always be called.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>The Loaded event will always fire after OnNavigatedTo (even when pages are being cached by setting NavigationCacheMode.Required).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/********************************************\n\t\/\/********************************************\n\t\/\/********** PAGE ABOUT TO BE SHOWN **********\n\t\/\/********************************************\n\t\/\/********************************************\n\tprivate void Page_Loaded(object sender, RoutedEventArgs e)\t\t\/\/&lt;&lt;&lt;&lt;Create event from .xaml event handlers!\n\t{\n\n\t}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Unloaded (call is say Page_Unloaded)<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/************************************************\n\t\/\/************************************************\n\t\/\/********** PAGE NO LONGER BEING SHOWN **********\n\t\/\/************************************************\n\t\/\/************************************************\n\tprivate void Page_Unloaded(object sender, RoutedEventArgs e)\t\t\/\/&lt;&lt;&lt;&lt;Create event from .xaml event handlers!\n\t{\n\n\t}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">GotFocus &amp; LostFocus<\/h5>\n\n\n\n<p>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<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. &#8216;Loaded&#8217; for page loaded) Built In Methods when using the Frame navigation system of the main window with Pages OnNavigationFrom is [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[],"class_list":["post-203","post","type-post","status-publish","format-standard","hentry","category-pages"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=203"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/203\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}