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