by Santhakumar Munuswamy
Posted on 16 March 2015
Windows Phone 7
总览
本文介绍了如何使用Windows Phone 7 SDK为Visual Studio 2010中的“ Hello World”程序创建Windows Phone应用程序。
Windows Phone 7 SDK的先决条件如下
· 受支持的操作系统,例如Windows 7,带有Service Pack 2的Windows Vista
· 在系统驱动器上安装时需要可用磁盘空间
· 系统上最低要求为3GB Ram
Windows Phone Emulator需要DirectX 10或更高版本
它与带有Service Pack 1的Visual Studio 2010版本兼容
Windows Phone SDK包括以下内容
· Windows Phone模拟器中可用
· Windows Phone SDK 7.1程序集中可用
· 在Sliverlight 4 SDK和DRT中可用
· 在Windows Phone的WCF数据服务客户端等中可用。
注意: SDK没什么,它是一个软件开发套件
现在,我们将按照以下步骤使用Visual Studio 2010为Windows Phone创建一个新项目。
打开Visual Studio 2010 à文件 à单击新项目
然后,New Project Windows将显示如下

然后为Windows Phone选择Sliverlight à Windows Phone应用程序
输入名称,位置后,单击确定按钮。
然后,将出现“新建Windows Phone应用程序”窗口
选择目标Windows Phone OS版本,例如 Windows Phone OS 7.1 在下拉框中。然后,单击确定按钮。
之后 HelloWorldApps 项目已成功创建。

现在,我更改了HelloWorldApps项目中具有Hello World的页面标题。
XMAL代码
<phone:PhoneApplicationPage
x:Class="HelloWorldApps.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="Hello World" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"></Grid>
</Grid>
<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->
</phone:PhoneApplicationPage>
一旦程序成功执行并部署到Windows Phone仿真器上,输出如下

结论
我希望本文有助于理解如何使用Visual Studio 2010为Windows Phone 7创建示例程序。