Windows phone 7中的图像控件、资源和样式

图像控件:Image,如果在C#代码中动态更改Image的Source,那么会用到BitmapImage类,把BitmapImage赋值给Image.Source。

资源:是Silverlight中任何可重用的值。

    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"

这种设置属性的样式叫做绑定语法。

但是在项目中又找不到PhoneFontFamilyNormal这样的资源,这是因为在WP7设备本身已经有了嵌入的资源文件。

比如要设置一个button的边框为静态资源,只需要

<Button Content="OK" Margin="40" BorderBrush="{StaticResource PhoneAccentBrush}" />

在VS中自己创建样式,比如要为一个button设置前景色,点击button的property,找到Foreground,先设置好前景色,再如图

如果要自己创建样式,比如自己设置button的style,需要加入一下代码

    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="buttonStyle" TargetType="Button">
            <Setter Property="BorderBrush" Value="Red" />
            <Setter Property="Foreground" Value="Red" />
        </Style>
</phone:PhoneApplicationPage.Resources>


在button中需要写入
Style="{StaticResource buttonStyle}"

如果想把Style设置成全局的,那么把
        <Style x:Key="buttonStyle" TargetType="Button">
            <Setter Property="BorderBrush" Value="Red" />
            <Setter Property="Foreground" Value="Red" />
        </Style>

加入到App.xaml的
    <Application.Resources>
    </Application.Resources>

标签中

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值