Vitalii Vasylenko
Vitalii Vasylenko

Reputation: 4876

Set TextBlock's Foreground in the Style

Is it possible to set Foreground property from the Style? Looking like it has no effect.

<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>

Upvotes: 0

Views: 964

Answers (1)

Anobik
Anobik

Reputation: 4899

It's simple be sure you bind it to a static resource

<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" />

Youll be able to see the effect in the xaml designer only

Upvotes: 1

Related Questions