Device Development for Windows Phone

Source: Internet
Author: User

The default project is "vertical only"

If you look at the header information of the mainpage. XAML file, you will find two attributes: supportedorientations = "portrait" orientation = "portrait"

You can think of supportedorientations as a list of possible situations that you are going to support in the program. You can set supportedorientations to any of the following three values:

  • Portrait (default)
  • Landscape
  • Portraitorlandscape

The orientation attribute is how your program is presented at startup. It has more optional values, but remember to include them horizontally in supportedorientations if you want to start them in mode. The following is a list of orientation values:

  • Landscape
  • Landscapeleft (flip the phone to the left)
  • Landscaperight (flip the phone to the right)
  • Portrait
  • Portraitdown (normal vertical direction)
  • Portraitup (inverted)

You can see that in the above table, you can not only specify the vertical or horizontal direction, but also specify the arrangement of these directions. This allows you to start your application in your preferred direction.

Change Direction

There are two ways to change the device direction. First, set supportedorientation to portraitorlandscape so that the operating system can implement it for you. In most cases, this is not recommended because your application interface may no longer adapt to the screen. The second method is implemented by code.

You can see that many buttons are not in the screen at the horizontal corner. This is not an ideal user experience. The simple solution is to remove the title. I'm sure our users can see that this is a calculator. We can relay the buttons. If it makes sense for the program, do it!

Run the following code to determine and process the device direction.

Public customerpage () {initializecomponent (); orientationchanged + = new eventhandler <orientationchangedeventargs> (customerpage_orientationchanged ); // determine screen landscape and tree screen changes} // solve the data loading problem caused by screen landscape and tree screen changes void customerpage_orientationchanged (Object sender, orientationchangedeventargs E) {// if the number of pages on the horizontal screen is 5 If (E. orientation = pageorientation. landscapeleft | E. orientation = pageorientation. landscaperight) {pagecount = 5;} // if the number of pages on the portrait screen is 10 else if (E. orientation = pageorientation. portraitdown | E. orientation = pageorientation. portraitup) {pagecount = 10 ;}}

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.