Question

In this example, I have a TextBlock with a DropShadowEffect:

<TextBlock Foreground="Black" Text="All Tasks">
    <TextBlock.Effect>
        <DropShadowEffect ShadowDepth="1.2" 
                          Direction="270" 
                          Opacity="0.6" 
                          BlurRadius="1" 
                          Color="Red"/>
    </TextBlock.Effect>
</TextBlock>

This produces the following output:

output

If I set any Background color for the TextBlock, the shadow should disappear:

output

How can I set this property while keeping the drop shadow?

Was it helpful?

Solution

The DropShadowEffect doesn't disappear - it now applies to the whole rectangle.

This gives the desired effect:

<Border Background="Green">
    <TextBlock Foreground="Black" Text="All Tasks">
        <TextBlock.Effect>
            <DropShadowEffect ShadowDepth="1.2" 
                              Direction="270" 
                              Opacity="0.6" 
                              BlurRadius="1" 
                              Color="Red"/>
        </TextBlock.Effect>
    </TextBlock>
</Border>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top