IT tutorials
 
Mobile
 

Windows Phone 8 : Page Navigation - Navigation Using the NavigationService, Handling Page Navigation

3/28/2014 3:59:20 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

1. Navigation Using the NavigationService

The PhoneApplicationPage class exposes a public NavigationService property, which allows direct control over navigation.


Note

The NavigationService cannot be used to launch Internet Explorer to view an external URL. Instead, use either the WebBrowserTask, or open the page within the app using the WebBrowserControl. See the previous sections on external navigation using the Button and HyperlinkButton controls.


The NavigationService.Navigate method causes the frame to load the specified PhoneApplicationPage, like so:

NavigationService.Navigate(
    new Uri("/DirectoryName/PageName.xaml", UriKind.Relative));

The URI must be either a path relative to the project’s root directory, as shown in the previous example, or a relative component URI, such as in the following example:

NavigationService.Navigate(
         new Uri("/AssemblyName;component/PageName.xaml", UriKind.Relative));


Tip

The NavigationService cannot be used within the constructor of the PhoneApplicationPage because it is assigned after the page’s constructor has been called. Therefore, wait until the page’s OnNavigatedTo method is called or the Loaded event has occurred before using the NavigationService.


The NavigationService.Source property allows you to retrieve the URI of the current page. Setting the Source property performs the same action as using the Navigate method; the frame loads the page at the specified URI. See the following example:

NavigationService.Source = new Uri(
         "/DirectoryName/PageName.xaml", UriKind.Relative);

Routing is also enabled for the NavigationService, which means that mapped URIs can be used instead of relative URIs.

If you examine the API of the NavigationService, you will likely wonder what the difference is between the CurrentSource property and the Source property. The answer is that the CurrentSource property does not change until navigation has completed. Conversely, the Source property changes as soon as navigation is initiated.

Backward Navigation

The NavigationService maintains the app’s navigation history, via an internal Journal instance. This allows the GoBack method of the NavigationService to move to the previous page in the history stack.


Note

If the GoBack method is called, and the history stack is empty because the current page is the app’s start page, then an InvalidOperationException is raised. To determine whether the NavigationService is able to go back, query its CanGoBack property.


Forward Navigation

Unlike Silverlight for the browser, the GoForward method of the NavigationService does not allow forward navigation and will raise an InvalidOperationException when called. Consequently, the CanGoForward property always returns false.


Note

Forward navigation using the NavigationService is not supported.

2. Handling Page Navigation

The PhoneApplicationPage extends the System.Windows.Controls.Page class, which has a number of virtual methods called when the page is brought into view or removed from view by the PhoneApplicationFrame (see Figure 1).

Image

FIGURE 1 PhoneApplicationPage inherits page navigation methods.

The OnNavigatingFrom method is called before a page is removed from view by the PhoneApplicationFrame, and the OnNavigatedFrom method is called after navigation occurs. Conversely, the OnNavigatedTo method is called when the frame brings the page into view.

 
Others
 
- Windows Phone 8 : Page Navigation - URI Mapping
- Windows Phone 8 : Page Navigation - Passing Page Arguments Using Query Strings
- Windows Phone 8 : Page Navigation - Navigation Using Unmapped URIs
- Windows Phone 8 : Understanding the Application Execution Model - Running Under the Lock Screen - Lock Screen Management
- Windows Phone 8 : Understanding the Application Execution Model - Implementing Fast App Resume - Optimizing the Resume Experience
- Windows Phone 8 : Exploring the Execution Model (part 4) - Restoring Transient State, Saving Persistent State
- Windows Phone 8 : Exploring the Execution Model (part 3) - Programmatically Exiting an App , Saving Transient State
- Windows Phone 8 : Exploring the Execution Model (part 2) - Life Cycle Events
- Windows Phone 8 : Exploring the Execution Model (part 1) - Application State
- Windows Phone 7 to Windows Phone 8 : App publication (part 7) - Selective targeting - Device memory
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us