Let you know why the screen changes when your phone turns (page display switch)-Windows Phone 7 Platform

Source: Internet
Author: User

Open the development environment of Windows Phone 7 and create a new project to modify the title and Application name of the home page. Because Chinese characters are not supported for the time being, they are all named in English. create three buttons on the XAML page, named portraitpage, landscapepage, and neutralpage respectively, and double-click the button to add a click event. The code for each button event is as follows:

    private void onPortraitPage(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/PortraitPage.xaml", UriKind.Relative));
}

private void onLandscapePage(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/LandscapePage.xaml", UriKind.Relative));
}

private void onNeutralPage(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/NeutralPage.xaml", UriKind.Relative));
}

The code above shows three XAML, so we need to insert three XAML pages named protraitpage. XAML, landscapepage. XAML (note that when this XAML is inserted, the first page type is displayed on a horizontal screen) and neutralpage. XAML;

Encode protraitpage. XAML and neutralpage. XAML:

Insert a row under initializecomponent (); in public page1 () in protraitpage. XAML

    SupportedOrientations = SupportedPageOrientation.Portrait;

Neutralpage. XAML:

Initializecomponent (); in public page3 (), insert a row

    SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
Now you can run it. You can see:
The page displayed by clicking the protrait button is still erected; the landscape page is changed to a horizontal one; when clicking the neutral button, the page is displayed as a portrait when the mobile phone is portrait, and if the mobile phone is crossed, the page is crossed;
-- That's why some mobile phones are switching from horizontal to vertical pages.

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.