【问题标题】:Set TextBlock's Foreground in the Style在 Style 中设置 TextBlock 的前景
【发布时间】:2013-09-28 18:23:13
【问题描述】:

是否可以从 Style 中设置 Foreground 属性?看起来好像没有效果。

<Style x:Key="MyPageNameStyle" TargetType="TextBlock">
    <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}" />
    <Setter Property="Margin" Value="0,12,0,0"/>
    <Setter Property="Foreground" Value="Green"/>
</Style>

【问题讨论】:

  • 它非常适合我。

标签: xaml windows-phone-7 styles microsoft-metro


【解决方案1】:

确保将其绑定到静态资源很简单

<Grid.Resources>
        <Style x:Key="MyPageNameStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}" />
            <Setter Property="Margin" Value="0,12,0,0"/>
            <Setter Property="Foreground" Value="Green"/>
        </Style>

    </Grid.Resources>
    <TextBlock Style="{StaticResource MyPageNameStyle}" Text="WP8 Demodccxzcxzczsczczxcxzczczczcz" Margin="9,-7,0,0" />

您只能在 xaml 设计器中看到效果

【讨论】:

    猜你喜欢
    • 2012-09-25
    • 1970-01-01
    • 2019-05-31
    • 2014-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    相关资源
    最近更新 更多