0

是否可以从样式中设置 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>
4

1 回答 1

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 设计器中看到效果

于 2013-09-28T19:15:42.070 回答