In Windows Phone 7, there are two screen directions: Portrait and landscape. in XAML, there are two attributes to set the display direction of the screen, and the screen display direction at startup:
The supportedorientations attribute sets the display direction that can be supported by the screen. Generally, it is set to one of the following three values:
Portrait: only portrait screen is supported. Landscape: only horizontal screen is supported.
Portraitorlandscape: indicates that the screen can be switched between the portrait screen and the horizontal screen.
The orientation attribute sets the display direction when the screen is started: Generally, it sets portrait or landscape ).
For example:
Supportedorientations = "portraitorlandscape" orientation = "portrait"
That is, you can set this page to support both landscape and landscape screens. When the page is started, it is started with landscape screens.
At the same time, we can also set the screen direction in the C # code, for example:
Supportedorientations = Supportedpageorientation. portraitorlandscape;
That is, you can set the orientation of the screen to support both landscape and landscape screens.
In addition, the horizontal direction can be divided into landscaperight and landscapeleft, indicating that the mobile phone buttons at the horizontal start are left or right. Likewise, the vertical direction can be divided into two situations: portraitup and portraitdown.
If we want to perform some operations or some functions that we have added when switching the screen direction (such as hiding a control or displaying some information ), we can rewrite the page's orientationchanged event, for example:
OrientationChanged + = newEventHandler <OrientationChangedEventArgs> (OnePicture_OrientationChanged);
void OnePicture_OrientationChanged (objectsender, OrientationChangedEventArgse)
{
// Add your own rewrite generation
}