代码改变世界

WP7备注(15)(Resources)

2011-04-28 11:38  血糯米Otomii  阅读(213)  评论(0编辑  收藏  举报

资源存放地点:

<phone:PhoneApplicationPage>
<phone:PhoneApplicationPage.Resources>
</phone:PhoneApplicationPage.Resources>
</phone:PhoneApplicationPage>
<Application>
<Application.Resources>
</Application.Resources>
</Application>

资源示例:

<phone:PhoneApplicationPage.Resources>
<Style x:Key="txtblkStyle"
TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="12 96" />
<Setter Property="FontSize" Value="48" />
<Setter Property="Foreground">
<Setter.Value>
<LinearGradientBrush>
<GradientStop Offset="0" Color="Pink" />
<GradientStop Offset="1" Color="SkyBlue" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</phone:PhoneApplicationPage.Resources>
<TextBlock Text="Hello, Windows Phone 7!" Style="{StaticResource txtblkStyle}"/>