Wpf Dropshadow remove offset

1k views Asked by At

Is there a way to set shadow effect with 0 offset?

It's ugly when I set this effect on a border. I am trying to reproduce the box-shadow css property

here in my hud

Here a sample of code to have some context:

<Border 
    BorderThickness="1,0,0,1"
    Grid.Column="1"
    Grid.Row="0"
    >
        <Border.Effect>
            <DropShadowEffect Direction="360" ShadowDepth="5" />
        </Border.Effect>

        ...

</Border>
2

There are 2 answers

3
s_mg_ On

Try something like this:

<DropShadowEffect ShadowDepth="3" BlurRadius="3" Opacity="0.5" />

You probably want to give your Border some margin too, else the shadow will expand further than you want

0
Robin L On

Set ShadowDepth to 0, this can remove offset completely.

<DropShadowEffect ShadowDepth="0" BlurRadius="12" Opacity="1" Color="Red" />

enter image description here

ShadowDepth controls offset size, and Direction controls angle

<DropShadowEffect Direction="180" BlurRadius="12" ShadowDepth="12" Color="red"/>

enter image description here