"Windows Phone 8 Development Internals" Reading notes -1-2-2-serial

Source: Internet
Author: User

Chapter II: Application Models and navigation (2)

Core issues in this chapter:

    1. The life cycle of an application
    2. The Navigation model of Microsoft page-based Silverlight application framework

We discussed the operating mechanism of WP, and now we go on to discuss the recovery strategy of WP:

In wp7.x, when we return to the application (without exiting) and then activate the application again, we can see from the previous article that it was restored in accordance with the epitaph state stored in the system, which is a slow process. Microsoft has introduced a new technology-recovery strategy (resume policy) for us in WP8, which allows applications to recover more quickly. The use of this strategy makes the application storage stack has an instance of the currently exiting application, and when we switch back, we call the instance of the object directly, thus appearing to respond faster.

When the program foreground is running, we press the window key to switch the program to the background. At this time, WP8 default fast recovery method is long press the back key, and we click on the Shelltile or the main program tile or program list icon to run the program, the program will jump to the history page stack of the latest page, jump parameter E. NavigationMode = = Navigationmode.reset, then automatically executes a new jump to the program default startup page or shelltile the specified page, and then cleans up the history page stack.

So, in order to run the program when you click on the main program tile or the program list icon to quickly revert to the last page, we need to cancel the new jump that was executed automatically, and keep the history page stack:

1. We need properties->wmappmanifest.xml

Figure 1-1: Setting the recovery policy

<= "_default"  navigationpage= "MainPage.xaml"  Activationpolicy= "Resume"/>

Navigationpage: Setting the startup page of the program

2. The Checkforresetnavigation method for modifying the App.xaml.cs file is as follows:

Private BOOL_isresume =false;//every time the page jump is completed, it is determined whether the recovery modePrivate voidCheckforresetnavigation (Objectsender, NavigationEventArgs e) {    //the framework will automatically jump to the program default startup page or shelltile the specified page when the program is currently quickly restored to the last browsed page    if(E.navigationmode = =navigationmode.reset) {//when fast recovery, decide whether to cancel automatic jump of frameRootframe.navigating + =handlerfotresetnavigating; _isresume=true; }    Else    {        if(_isresume && E.navigationmode = = Navigationmode.refresh)//the frame auto-jump is not performed when a quick restore triggered by the second click of the same tile{rootframe.navigating-=handlerfotresetnavigating; _isresume=false; }    }}

3. Implement Handlerfotresetnavigating Events:

//Quick Recovery Mode when the frame automatically jumps, here decide whether to cancel the jumpPrivate voidHandlerfotresetnavigating (Objectsender, NavigatingCancelEventArgs e) {rootframe.navigating-=handlerfotresetnavigating; if(E.uri.originalstring.contains ("MainPage.xaml"))//Click the program main tile or program list icon to enter, will jump to the default program launch page, then cancel the jump, revert to the history page stack the latest page{E.cancel=true; }    Else //Click Shelltile to enter, jump shelltile The specified page, do not cancel the jump, and clear the history stack after the jump is complete{rootframe.navigated+=Clearbackstackafterreset; } _isresume=false;}

Second, the page navigation model

WP's navigation model is similar to the traditional Web navigation (jump between pages, the use of URLs to navigate, or one application to navigate to another application), usually WP page number is maintained between 4-10, you can also have more pages, the corresponding will also need to consume more system resources.

Figure 1-1:WP Page Navigation model

PS: This navigation process can be considered as a stack and a stack, combined with the browser's forward and backward principle is a good understanding of the process.

WP this page-by-app, app-to-page navigation model creates a seamless user experience.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.