Learn about Windows Phone7 Development (10. Windows Phone 7 Ctp-april to the beta release)

Source: Internet
Author: User

Windows Phone 7 has a total of three versions of the SDK from release to now and is incompatible. Before I wrote the first edition to the second edition of the migration, now look at the second edition to the beta version of the changes.

A App.xaml and App.cs

1.app.xaml

The file looks a lot lighter than it used to be, and it also seems to have something to do with the new simulator style, with no large sections of code. But this will be a problem, the original property item did not, resulting in the original page load error.

A. Change the Phonetextpagetitle2style to Phonetextnormalstyle or add one such attribute.

B.

<Application.RootVisual>
         <phoneNavigation:PhoneApplicationFrame x:Name="RootFrame" Source="/MainPage.xaml"/>
     </Application.RootVisual>

This item was canceled. Thus causing the application to not start. The rootframe of this setup program is placed in the configuration file.

2.app.xaml.cs

The same document has also changed. The changes are also relatively large. Need to add and remove some code (here's the code for the APPP Class):

public partial class App:application
{
Public Phoneapplicationframe Rootframe {get; private set;}

Constructor
Public App ()
{
Global handler for uncaught exceptions.
Note This exceptions thrown by Applicationbaritem.click won't get caught here.
UnhandledException + = application_unhandledexception;

Standard Silverlight Initialization
InitializeComponent ();

Phone-specific initialization
Initializephoneapplication ();
}

Code to execute when the application was launching (eg, from Start)
This code won't execute when the application is reactivated
private void Application_launching (object sender, Launchingeventargs e)
{
}

Code to execute when the application was activated (brought to foreground)
This code would not execute when the application is the launched
private void Application_activated (object sender, Activatedeventargs e)
{
}

Code to execute when the application was deactivated (sent to background)
This code won't execute when the application is closing
private void Application_deactivated (object sender, Deactivatedeventargs e)
{
}

Code to execute when the application was closing (eg, user hit back)
This code won't execute when the application is deactivated
private void Application_closing (object sender, Closingeventargs e)
{
}

Code to execute if a navigation fails
void Rootframe_navigationfailed (object sender, Navigationfailedeventargs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
A Navigation has failed; Break into the debugger
System.Diagnostics.Debugger.Break ();
}
}

Code to execute on unhandled exceptions
private void Application_unhandledexception (object sender, Applicationunhandledexceptioneventargs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
An unhandled exception has occurred; Break into the debugger
System.Diagnostics.Debugger.Break ();
}
}

#region Phone Application Initialization

Avoid double-initialization
private bool phoneapplicationinitialized = false;

Do don't add any additional code to this method
private void Initializephoneapplication ()
{
if (phoneapplicationinitialized)
Return

Create the frame but don ' t set it as rootvisual yet; This allows the splash
Screen to remain active until the application are ready to render.
Rootframe = new Phoneapplicationframe ();
rootframe.navigated + = completeinitializephoneapplication;

Handle Navigation Failures
rootframe.navigationfailed + = rootframe_navigationfailed;

Ensure we don ' t initialize again
Phoneapplicationinitialized = true;
}

Do don't add any additional code to this method
private void Completeinitializephoneapplication (object sender, NavigationEventArgs e)
{
Set the root visual to allow the application to render
if (rootvisual!= rootframe)
RootVisual = Rootframe;

Remove This handler since it is no longer needed
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.