App file for Windows Phone development

Source: Internet
Author: User
Using system; using system. collections. generic; using system. LINQ; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. navigation; using system. windows. shapes; using Microsoft. phone. controls; using Microsoft. phone. shell; namespace microblogforwp7 {P Ublic partial class app: Application {public phoneapplicationframe rootframe {Get; private set ;} /// <summary> /// construct the Application Object /// </Summary> Public app () {// execute unhandledexception for unhandled exceptions + = application_unhandledexception; // initialize Silverlight initializecomponent (); // initialize initializephoneapplication () for specific applications; // view information displayed for debugging if (system. diagnostics. debugger. isattached) {// display the current frame rate counter. Application. Current. Host. settings. enableframeratecounter = false; // display the area where the application is repainting each frame. Application. Current. Host. settings. enableredrawregions = false; // allows the visualization mode of non-production analysis. // This indicates that a color print is handed over to the GPU page area. Application. Current. Host. settings. enablecachevisualization = false; // disable the app idle detection. The set useridledetectionmode attribute // the app's phoneapplicationservice object is disabled. // Note:-This is only used in debugging mode. Applications that disable idle detection will continue to run // and consume battery power when the user does not use the phone. Phoneapplicationservice. current. useridledetectionmode = idledetectionmode. disabled;} // when the code application to be executed is started (for example, starting from ") Private void application_launching (Object sender, launchingeventargs E) {} // Private void application_activated (Object sender, activatedeventargs E) {} // the code to be executed when the application is closed (the background operation is not activated) Private void application_deactivated (Object sender, deactivatedeventargs e ){} // Close the private void application_closing (Object sender, closingeventargs e) when the Code executes the application (for example, the user closes) {}// private void rootframe_navigationfailed (Object sender, navigationfailedeventargs e) {If (system. diagnostics. debugger. isattached) {system. diagnostics. debugger. break () ;}}// execute the unhandled exception private void application_unhandledexception (Object sender, applicationunhandledexceptioneventargs e) {If (sys TEM. diagnostics. debugger. isattached) {system. diagnostics. debugger. break () ;}# region phone application initialization // avoid repeated private bool phoneapplicationinitialized = false; private void initializephoneapplication () {If (phoneapplicationinitialized) return; rootframe = new phoneapplicationframe (); rootframe. navigated + = completeinitializephoneapplication; // handle the navigation fault rootframe. navigationfaile D + = rootframe_navigationfailed; // do not initialize phoneapplicationinitialized again = true;} private void completeinitializephoneapplication (Object sender, navigationeventargs e) {// set the root vision, to allow applications to render if (rootvisual! = Rootframe) rootvisual = rootframe; // Delete this handler rootframe. navigated-= completeinitializephoneapplication;} # endregion }}

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.