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 }}