Preface
The previous article describes how to build a development environment for Windows Phone 7.ArticleDescribes how to create, deploy, debug, and run a Silverlight for Windows Phone application.ProgramAnd describes how to use Microsoft Visual Studio 2010 express for Windows Phone and Windows Phone emulator (simulator. In this article, a Silverlight for Windows Phone application called silverradio will be created. I named it silver radio, which is used to listen to network radio programs.
Create a Silverlight for Windows Phone Project
Click Start> All Programs> Microsoft Visual Studio 2010 express> Microsoft Visual Studio 2010 express for Windows Phone. Start Microsoft Visual Studio 2010 express for Windows Phone
Under the File menu, click New project.
In the new project dialog box, select the Silverlight for Windows Phone template directory, select the Windows Phone application template, name the project as silverradio, and click OK.
A Silverlight for Windows Phone project is successfully created. Let's take a look at the files created by the Windows Phone application template for us.
File structure generated by the Template
In Solution Explorer, you can see the following directory structure and files created by the Windows Phone application template for the silverradio project.
App. XAML and App. XAML. CSDefine the entry point of the program, and initialize the Global static resource (staticresource) at the application level and the page for starting the program. In beta, some global resource definitions are removed from app. XAML.Source codeFor more information about global static resources, see Theme resources for Windows Phone.
Mainpage. XAML and mainpage. XAML. CSDefines a UI page. Generally, a template of the Silverlight program generates a page called mainpage. XAML and mainpage. XAML. the cs ui page serves as the default UI, but the UI startup page does not have to take mainpage as the name. Using mainpage is just a convention. If you need to modify the first startup page, you can modify the following in wmappmanifest. xml:Code.
<Tasks> <DefaulttaskName="_ Default"Navigationpage="Mainpage. XAML"/> </Tasks>
Applicationicon.pngIs the icon displayed in the phone application list, for example, the silverradio icon is displayed in the simulator below.
Background.pngThe icon used for Start Screen Display.
Splashscreenimage.jpgAfter the program is started, the image displayed before the first page is started.
Properties \ appmanifest. xmlDefines the manifest file ). The Silverlight program will eventually compress into an xap package. This xap package is a zip file that contains all the resources required by the Program (for example, audio files, and so on ), and third-party DLL. The appmanifest. xml file is used to define the packaging structure for the generated xap.
If you change the silverradio.xapfile name to silverradio.zip and decompress it, you can see all the files when the program is released. The structure of these files is defined by appmanifest. xml.
Properties \ assemblyinfo. CSThis file contains the version information and other source data (metadata). This file is consistent with the assemblyinfo. CS file function in ASP. NET and winform programs.
Properties \ wmappmanifest. xmlAnd appmanifest. XML is also a packaging file used to define the program, but wmappmanifest. XML specifies the source data (metadata) related to the Windows Phone Silverlight application, such as the mainpage on the startup page. the definition of XAML is included in wmappmanifest. XML.
Generally, do not manually modify the wmappmanifest. xml and appmanifest. xml files. You can modify them using the project properties file. For example:
Right-click a project and choose Properties From the shortcut menu.
The modified attributes are kept in the wmappmanifest. xml and appmanifest. XML files.
References folderDisplays dependent DLL and other related resources. Because Windows Phone beta combines multiple DLL files into Microsoft. phone. DLL, so the project contains Microsoft. phone. DLL and Microsoft. phone. interOP. DLL two Windows Phone related DLL (the CTP version contains more other DLL), if you need to use other DLL, for example, in our series of textbooks will use LINQ for XML, then the system. XML. LINQ. DLL is added to the references folder.
The full text cannot be published because it is published in programmer magazine. For the full text, see Silverlight for Windows Phone 7 Development Series (2): The first Silverlight Program