Windows Phone development path (10) the first program to enter WP

Source: Internet
Author: User

The basic knowledge of XAML and Silverlight was introduced earlier to start the official development of WP.ProgramNow that we have basic knowledge, we can officially start WP program development. First, I will start from creating a hello Windows Phone program. Please do not underestimate this seemingly simple program. In fact, it is the basis for developing complex programs. Next we will create a new Windows Phone application program.

1. Introduction to the project composition File

After creating a new project, we found that vs has automatically generated some files for us. What are their respective roles?
1. The properties node contains three files. Two XML files and the assemblyinfo. CS file are used to define the features of the application.
2. There are three image files in the root directory. Applicationicon.png?application icons, background.png=application startflat image background, and splashscreenimage.jpg indicates the image placeholder when the application is loaded (or started.
3. App. XAML and App. CS files. App. XAML is used to store resources used by the entire application (under the node <application. Resources>). These resources include color schemes, gradient brushes, and styles. The app. CS file is used to define the entry point of an application.
4. mainpage. XAML and mainpage. CS files. Mainpage. XAML is equivalent to the home page of the application, while mainpage. CS is mainly used to compile the event processing program.Code.

Most of our time will be spent on mainpage. XAML and App. XAML files.

2. Establish the first WP Program

We want to achieve a text display in the center of the display screen. We insert a new textblock in the grid named contentpanel.
XAML code:

 
<Grid X: Name ="Contentpanel"Grid. Row ="1"Margin ="12, 0, 12, 0">
<Textblock text ="Hello Windows Phone!"Horizontalalignment ="Center"Verticalalignment ="Center"/>
</GRID>

Effect

Note,There are three important attributes. The text attribute indicates the text content of textblock, which belongs to the string type. The horizontalalignment and verticalignment attributes indicate horizontal and vertical alignment. They are all Enumeration type. You only need to set them to their member names.

3. theme color

The WP7 subject contains the background and accent colors. The background colors include dark (dark background, light text) or light (light background, dark text ). To set a theme, click or touch the right arrow in the upper-right corner of the Start Screen of the phone or phone simulator to find the setting and select theme ). The following example shows the effect of setting it to a dark or light background.
Dark background light background

Although these colors are automatically applied,However, we can also customize the color of text display, which can be achieved through the foreground attribute in the textblock tag.The following figure shows the effect after foreground is set to "red,

The above is the content of the first WP program. The next article will summarize the content related to processing in WP. I will use examples to summarize each knowledge point, this helps us quickly master the WP development technology.

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.