Windows Phone development (1)-development environment and structure

Source: Internet
Author: User

I haven't written a blog for a long time. After I finished my previous MSN project, it was a trivial task. Then I was playing photography and traveling. I went to Tibet on vacation last month. It's really good. Back, you have to learn it. The development tool for Windows Phone 7.1 has been released and has been very concerned about WP7. Now we can start learning. In fact, I learned Silverlight in and read the SDK documentation in 3. At that time, I did not stick to it because of my work. So I learned WP7 and re-learned SL this time.

 

I installed the wp7.1 Development Environment last week and read the documents for one week after work. At present, most of the learning documents on WP are in English. A Chinese book is published on Chian-Pub. However, we recommend that you read the latest wp7.1 content on msdn, after all, 7.1 is greatly updated. I wrote Windows Phone development articles mainly to extract and record my own documents, mainly for wp7.1beta.

 

 

 

1. Windows Phone learning materials

Currently, the main learning materials are Microsoft msdn and programming Windows Phone 7. msdn includes the latest 7.1beta features and usage. Some Chinese websites and original blog articles are also from these places. In every issue of msdn, there are articles about Windows Phone. For more information about interface development, see Silverlight development.

 

Windows Phone Chinese Development Center

Windwos phone Development

Silverlight for Windows Phone

Phone platform development

Windows Phone developer documentation

Programming Windows Phone 7

Video learning materials

Windows Phone 7 overview of chinese development materials

Msdn magazine

 

2. Windows Phone development environment

Microsoft released the latest development tool mango in May, May, Windows Phone Developer Tools 7.1 beta (click to download the ISO file)

 

System Requirements:

  • Operating System: Windows Vista SP2/Windows 7
  • Hardware requirements: 4 GB hard drive space, 3 GB memory
  • Mobile phone simulator: directx10 or above graphics card, wddm1.1 driver

PS: My laptop is t2450 + 3G memory + hd2300 video card. It has been running properly since.

 

Installation preparation:

  • If vs2010 is not installed, install Windows Phone Developer Tools 7.1 beta.
  • If vs2010 Professional edition or a later version is installed, you can install it directly, but you must change the language of vs2010 to the same language as Windows Phone Developer Tools 7.1 beta.
  • If vs2010 RTM version is installed, vs2010 SP1 must be installed first (click to download the ISO file)
  • If a non-English version of Windows Phone Developer Tools 7.0 or expression blend is installed, you must uninstall it before installation.

PS: I have installed vs2010 Chinese flagship edition, So I first installed SP1 (the first time I reached half of it, I stopped it. Later I checked that there may be a lack of files, load the ISO of vs2010 to the virtual optical drive and then pass.) However, because Windows Phone Developer Tools 7.1 beta is only available in English, after installation is complete, the WP7 development template is not integrated in vs2010, but the development environment of xNa game studio is integrated. Instead, vs2010 express for Windows Phone is installed.

 

 

 

 

3. The first Windows Phone 7 program

We can see that there are many templates to choose from. The following is a brief introduction. You can create a project to view details.

  • Windwos phone application: create a common Windows Phone application
  • Windwos phone databound application: Creates a project related to data binding and uses list and navigation controls.
  • Windows Phone Class Library: Create a class library project
  • Windwos phone panorama application: Creates a panoramic application project using the panoramic panorama control.
  • Windwos phone pivto application: Create a pivot application project using the pivto Control
  • Windwos phone 3D graphics application: Create a project supported by the xNa framework (wp7.1 can be integrated with Silverlight and xNa)
  • Windwos phone audio playback application: Creates a class library project for audio playback.
  • Windwos phone audio streaming application: Creates a class library project for audio streams.
  • Windwos phone Task Scheduler agent: Creates a background task proxy project (a background multi-task proxy is added to wp7.1)

After selecting a project template, You must select the development version of Windows Phone. Currently, you can select 7.0 and 7.1.

 

 

It is the development environment of WP7. If Silverlight has been developed, it should not be unfamiliar. The left side is the graphic interface environment, and other. NET development environments are the same. You can drag controls to layout them. The right side is the page's XAML code, which can be laid out by compiling the XAML. For more information about XAML, see msdn (click to open it)

 

What we need to implement in our first program is to click a button on the page and navigate to the next page:

1. Add a button in mainpage. XAML and add a touch screen event. The Code is as follows: [XHTML: Collapse]+ Expand sourceview plaincopyprint?
  1. <Grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 250 "> <button width =" "Height =" 75 "content =" next page "manipulationstarted =" button_manipulationstarted "/> </GRID>
<Grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 250 "> <button width =" "Height =" 75 "content =" next page "manipulationstarted =" button_manipulationstarted "/> </GRID>2. Add a new page for the Project, right-click -- add -- new item -- Windows Phone portrait page, and name it page1.xaml. Add a text and a return button to the next page, the Code is as follows: [XHTML: Collapse]+ Expand sourceview plaincopyprint?
  1. <Grid X: Name = "contentpanel" grid. row = "1" margin = "166,143,178,"> <textblock verticalignment = "TOP" horizontalalignment = "center" margin = ", 0"> Hello world! </Textblock> <button width = "200" Height = "75" content = "back" manipulationstarted = "button_manipulationstarted"/> </GRID>

<Grid X: Name = "contentpanel" grid. row = "1" margin = "166,143,178,"> <textblock verticalignment = "TOP" horizontalalignment = "center" margin = ", 0"> Hello world! </Textblock> <button width = "200" Height = "75" content = "back" manipulationstarted = "button_manipulationstarted"/> </GRID> 

 

3. Add code for mainpage. XAML touch-screen events and page1.xaml touch-screen events (like other projects in C #, code-behind is also used, and the code is in the CS file on the XAML page) [C-sharp: Collapse]+ Expand sourceview plaincopyprint?
  1. // Mainpage. xamlprivate void button_manipulationstarted (Object sender, manipulationstartedeventargs e) {This. navigationservice. navigate (New uri ("/page1.xaml", urikind. relative);} // page1.xamlprivate void button_manipulationstarted (Object sender, manipulationstartedeventargs e) {This. navigationservice. goback ();}

// Mainpage. xamlprivate void button_manipulationstarted (Object sender, manipulationstartedeventargs e) {This. navigationservice. navigate (New uri ("/page1.xaml", urikind. relative);} // page1.xamlprivate void button_manipulationstarted (Object sender, manipulationstartedeventargs e) {This. navigationservice. goback ();}

 

4. After compilation, run the program at F5. Wait for the first startup of the simulator (I have no real machine, so I cannot debug it ). Click Next page to navigate to the second page. In the second interface, click back to navigate back to the previous interface. It can be found that the Windows Phone program is a little similar to the Web application page, which is a concept of page navigation, which is very different from the former WM platform. However, if you have used WPF or Silverlight, there is nothing special about it. 5. After entering the second page, click <--] to return to the first page. Click <--] to close the program. Note that Windows Phone does not currently provide any exit Method for exiting the program. You can exit the program by clicking <--] on the first page. Click the "home" button in the middle of the program to return to the home list. At this time, the program enters the sleep (wp7.1) or tombstone (wp7.0) status, which will be described later.

So far, we have completed the first Windows Phone program, which is very simple and looks no different from writing a common Silverlight program.

 

 

4. Windows Phone project structure

After the project is created, it contains the following files:

  • Appmanifest. xml: This file contains a <deployment. Parts> node. If you need to call the DLL files of other assemblypart contained in the xap file, a <assemblypart/> node is added to the node to list these files. For more information, see here.
  • Assemblyinfo. CS: This file contains information about the current Assembly. You can set it on the properties page.
  • Wmappmanifest. xml: This file mainly records the starting page of the program, appid, author, icon settings, and program function settings. The <capabilities/> node defines the functions of the program. For example, id_cap_phonedialer indicates that the telephone function can be used. If this node is not available, an error occurs when calling the corresponding function. For details, see here. Compared with 7.0, 7.1 adds the camera, contact, and appointment reminder function.
  • App. XAML: This file app class inherits from the application class and has no visual interface. <application. Resources/> is generally used to store resource data for global use. The <application. applicationlifetimeobjects/> node defines some methods related to the execution model.
  • App. XAML. CS: Another part of the app class. The Code contains the implementation of some methods related to program initialization and execution model.
  • Applicationicon.jpg: The icon displayed in the program list. The size is 62*62.
  • Bcakground.jpg: The icon displayed when the program starts. The size is 173*173 S.
  • Mainpage. XAML: The first page displayed by default after the program starts. You can also specify the start page in wmappmanifest. xml.
  • Splashscreenimage.jpg: The welcome page displayed when the program starts. The size is 480*800, which is related to the device.

The above describes the structure of a Windows Phone project, which is similar to the Silverlight program structure. But there are some differences in the configuration file.

 

 

Summary

Here we have completed the establishment of the Windows Phone 7.1 environment and the first Windows Phone program. We have an understanding of the program template and project structure. The next article will introduce the Windows Phone framework structure and how the program starts and runs.

 

From: http://blog.csdn.net/cc_net/article/details/6552867

I think he wrote well and recommended it to everyone.

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.