Noah
Noah

Reputation: 15320

How do I set the text opacity different from the background opacity in a Silverlight textbox

My XAML contains in part

<TextBox Text="PROJECTED"
         TextAlignment="Center"
         FontSize="11"
         FontWeight="Bold"
         Foreground="White"
         Background="#FF3376B8"
         Opacity="0.65" />

However, this causes the text to also be 65% opaque;

How do I set the text to be 100% opaque but allow the background to be 65%?

Upvotes: 1

Views: 5113

Answers (3)

Joy Rex
Joy Rex

Reputation: 608

Try this.

<TextBox Text="PROJECTED"
         TextAlignment="Center"
         FontSize="11"
         FontWeight="Bold"
         Foreground="White"">
    <TextBox.Background>
        <SolidColorBrush Color="#FF3376B8"
                         Opacity="0.65" />
    </TextBox.Background>
</TextBox >

Upvotes: 0

RobSiklos
RobSiklos

Reputation: 8849

Do it by adjusting the Alpha channel of the Background property.

For example:

<TextBox Text="PROJECTED"
         TextAlignment="Center"
         FontSize="11"
         FontWeight="Bold"
         Foreground="White"
         Background="#883376B8" />

Upvotes: 2

Leslie Davies
Leslie Davies

Reputation: 4112

You can use the VS/Expression Blend property editor UI to adjust the opacity of any color property by adjusting the A value in your color's RGBA value (0....255, lower is more opaque)

This will obviously change the hex value of your color but will give you the view you're looking for.

Upvotes: 1

Related Questions