IT tutorials
 
Mobile
 

Windows Phone 8 : Page Navigation - Canceling Navigation, Cross-Page Communication

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

1. Canceling Navigation

The OnNavigatingFrom method offers the opportunity to cancel navigation using the NavigatingCancelEventArgs parameter.

NavigatingCancelEventArgs has the following properties:

- NavigationModeAn enum value that indicates the type of navigation. This value may be Back, Forward, New, or Refresh.

- UriThe destination URI.

- CancelSetting this value to true cancels the navigation.

The NavigationCancelEventArgs class subclasses CancelEventArgs, which provides the Cancel property. By setting this property to true, the page can prevent the navigation from occurring, as shown in the following excerpt:

protected override void OnNavigatingFrom(
    System.Windows.Navigation.NavigatingCancelEventArgs e)
{
    base.OnNavigatingFrom(e);
    MessageBoxResult boxResult = MessageBox.Show(
        "Leave this page?", "Question", MessageBoxButton.OKCancel);
    if (boxResult != MessageBoxResult.OK)
    {
        e.Cancel = true;
    }
}


Note

You should not attempt to cancel navigation in the OnNavigatingFrom method when the hardware Back button is pressed. Instead, override the OnBackKeyPress method to cancel the back key, which prevents navigation.

2. Cross-Page Communication

After navigation has occurred, an opportunity remains for the previous page to interact with the current page from the previous page’s OnNavigatedFrom method. This is achieved using the Content property of the NavigationEventArgs, which provides the destination PhoneApplicationPage object.

To see this in action, place a breakpoint in the OnNavigatedFrom method. When the breakpoint is hit, notice that the page being navigated to has already been instantiated and is provided in the Content property of the NavigationEventArgs (see Figure 1).

Image

FIGURE 1 The Content property of the NavigationEventArgs contains the page being navigated to.

The Uri property of the NavigationEventArgs contains the URI of the destination page, including any query string that may be present.


Note

If navigating to an external URI, or when the app is being deactivated, the Uri property of the OnNavigatedFrom method’s NavigationEventArgs is equal to app://external/.


 
Others
 
- Windows Phone 8 : Page Navigation - Navigation Using the NavigationService, Handling Page Navigation
- 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
 
 
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