Windows Phone Development (4): Frames and Pages

Source: Internet
Author: User
Tags silverlight

Before I do, I would like to correct a small problem before I said in the first article that the Chinese version of Visual Studio Express for Windows phone is not Simplified Chinese, that is because I am downloading on the English homepage, only one Chinese language selection list, but traditional, Later, I found the Windwos Phone SDK is available in Simplified Chinese version, and I also gave it.
Http:// familyid=0a373422-6680-46a7-89e1-e9a468a14259 can be installed online, if your speed is not power, you can download the ISO image local installation. ----------------------------------
In the previous article, we learned about the life cycle of WP applications and the triggering of individual events, and today we look at frames and pages. The theory of the withered things will not talk about, on MSDN have, specifically, we randomly create a WP application project, and then open the App.xaml.cs file to see if there is a "new continent"?
1, an app class, from
Application derivation, this is the same as in Silverlight, of course, if you are not familiar with the silerlight it does not matter, I simply blow.
I think you have played C #, anyway, you should have played the Windows Forms application, yes, we often say WinForm project, in the WindowsForm project, There is a file like Program.cs, the entry point of the program is defined inside, and at the end of main, there is a line in the code generated by the VS Default: Application.Run (...);
So, this application and that application meaning is the same, specifically responsible for the entire application scope of the coordination of various transactions.    2, we will notice that the app has a public property rootframe, this is the main frame, a WP application has only one main frame. 3, the main frame is the page, the main frame can contain 1 or more pages. 4, the concept of the page is very good understanding, like we usually see a form, but in Silverlight inside called page, so we can also associate with the Web page. In Android called an activity, actually refers to the east is the same, but the name is different.  is shown as a page. OK, here's a look at how a page is formed.
Let's take a look at the XAML Declarations section of the page.

  1. <phone:phoneapplicationpage
  2. X:class= "Phoneapp.mainpage"
  3. Xmlns= "Http://"
  4. xmlns:x= "Http://"
  5. Xmlns:phone= ";"
  6. Xmlns:shell= ";"
  7. Xmlns:d= ""
  8. Xmlns:mc= ""
  9. mc:ignorable= "D" d:designwidth= "480" d:designheight= "768"
  10. Fontfamily= "{StaticResource phonefontfamilynormal}"
  11. Fontsize= "{StaticResource phonefontsizenormal}"
  12. Foreground= "{StaticResource Phoneforegroundbrush}"
  13. supportedorientations= "Portrait" orientation= "Portrait"
  14. shell:systemtray.isvisible= "True" >
  15. ........................

As we can see, each page is a subclass of PhoneApplicationPage, which is the page class that inherits from Silverlight.
Because the program is for WP phones, it is important to use phoneapplicationpage instead of the page class to avoid problems. The class attribute is the category name of our page class. There are two namespaces we have to pay attention to:
Xmlns:d= ""
Xmlns:mc= "" D can be understood as a design-time state, d:designwidth= "480" That is, the width and height is only valid at design time, that is, we see in the designer size, does not mean that the real run is this value, it may be different from the phone screen automatically adjust, so we should not deliberately set the width and height of the page, so as not to be fixed, not automatically adjust. What is MC? Semantic translation is a markup compatibility-related content, where we see a phrase: mc:ignorable= "D", as mentioned above, D:designwidth is designed, so ignorable= "D" is to tell the compiler when it actually runs, Ignores the values set at design time. Supportedorientations is used to set the direction of the page support, if we want the phone screen to be rotated by the user, the program can automatically follow the adjustment, modify the property accordingly.
The Orientation property is used to set the default orientation of the current page, portrait or landscape.      Below, together to do a practice, the supportedorientations change to Portraitorlandscape, and then the orientation instead of the other than the value of the other, and then run, the phone to different directions to rotate, see how? This everyone to change, more than a few times to understand, very interesting. There is one, shell:systemtray.isvisible= "True" is used to set whether to hide the system tray, when we set it to True, run the program, move the mouse to the top of the page click, we will see the system tray, such as showing the current cell phone signal strength, Information such as the amount of battery remaining.

Windows Phone Development (4): Frames and 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: 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.