学习wp开发第一次总结
今天看了下wp开发书,顺便总结一下。
首先说下MainPage.xaml的页面结构。

<phone:PhoneApplicationPage x:Class="HelloWorld.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" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="True"> <!--LayoutRoot 是包含所有页面内容的根网格--> <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <!--TitlePanel 包含应用程序的名称和页标题--> <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> <TextBlock Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/> <TextBlock Text="页面名称" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> </StackPanel> <!--ContentPanel - 在此处放置其他内容--> <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <Button Content="Button" HorizontalAlignment="Left" Margin="154,190,0,0" VerticalAlignment="Top" RenderTransformOrigin="-2.143,0.741" Click="Button_Click"/> </Grid> </Grid> </phone:PhoneApplicationPage>
所有xaml代码都放在<phone:PhoneApplicationPage>里面,从上到下看,
x:Class这个是页面继承的类,也就是对应的隐藏代码里面的类。
xmlns这是默认的命名空间,如果页面控件没有前缀,那么代表它就是属于默认的命名空间。
xamlns:x这是代表专属空间,比如空间里面Name属性那么x:Name就是代表这个xaml的名字空间。
xmlns:phone这个是包含在wp的引用dll,
xmlns:shell包含在miscroft.shell里面的dll文件,可以帮助管理生命周期。
xmlns:d这是设计时的数据,而真正运行起来时会帮我们忽略掉这些运行时的数据。
xmlns:mc这是布局兼容性,主要配合xmlns:d使用。它包含Ignorable属性,可以在运行时忽略掉这些设计时的数据。
所有页面内容都全部放在layoutRoot的grid中。
App.xaml这个文件是程序的全局文件。里面可以放一些全局资源和应用程序的全局事件详细看书20-21页。
WMAppMainifest.xml文件主要是设置程序图标,可以使用的功能,和支持的分辨率等。
AppManifest.xml文件是生成应用程序所必须的应用程序清单文件。
AssmblyInfo.cs做过winform的人都知道,不必解释。