Some experiences and understandings during app. XAML execution [Windows Phone]

Source: Internet
Author: User

Since Windows Phone is developedCodeData initialization and loading are always confusing. I recently checked and compiled data on the Internet.ProgramI would like to share with you some knowledge about the execution process of APP. XAML.

App. XAML and App. XAML. CS define the entry point of the program, initialize global resources at the application level, and display the program UI.

Create a Silverlight or Windows Phone program.

1. First, pay attention to the application. applicationlifetimeobjects node definition in the app. XAML file.

<Application. applicationlifetimeobjects>
<! -- Required object that handles lifetime events for the Application -->
<Shell: phoneapplicationservice
Launching = "application_launching" Closing = "application_closing"

Activated = "application_activated" Deactivated = "application_deactivated"/>
</Application. applicationlifetimeobjects>

The following four events are registered: launching, closing, activated, and deactivated.

Application_launching is called when the program is started, and application_closing is called when the program is exited.

Application_deactivated is called when another program is started, and application_activated is called when the program is returned.

2. There is an initializephoneapplication () in the constructor app (). Pay attention to the role of this function. Let's see how it is defined:

 
Private void initializephoneapplication ()
 
{
 
If (phoneapplicationinitialized) // prevents secondary Initialization
 
 
 
Return;
 
// Create the frame but don't set it as rootvisual yet; this allows the splash
 
// Screen to remain active until the application is ready to render.
// Initialize the program framework, and do not copy rootvisual for the time being. This allows the splash to display and know that the program render is complete.
 
Rootframe = new phoneapplicationframe ();
 
Rootframe. navigated + = completeinitializephoneapplication;
 
// Processing program navigationg failed
 
// Handle navigation failures
 
Rootframe. navigationfailed + = rootframe_navigationfailed;
 
 
 
// Ensure we don't initialize again
 
Phoneapplicationinitialized = true;
// Initialization is complete. Initialization is not completed.
 
}

After the rootframe is loaded, assign the rootframe value to the rootvisual of the program, so that mainpage. XAML is displayed.

3. Why is mainpage displayed?

This is defined by the node in wmappmainfest. xml. You can change it to any page you like.

Wmappmainfest. xml specifies the metadata related to the Windows Phone Silverlight application. There is the default navigationpage = "mainpage. XAML" in it. To navigate other pages, you only need to rewrite your favorite pages.

<Tasks>
<Defaulttask name = "_ default" navigationpage = "mainpage. XAML"/>
</Tasks>

The Silverlight program will eventually implement the xap package, which is a zip file containing all the resources required by the program. One interesting thing is to go to phoneapptest in the bin \ debug folder. xap changes the xapsuffix to the. ZIP format, decompress it, and a pile of files will appear, including image information, audio, and third-party DLL information.

The above is a little bit of understanding in the Internet query and use process, the shortcomings, please correct.

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.