Search code examples
c#wpfwindowsxaml

How to make Shadow effect with no direction in Windows wpf xaml?


My xaml code is as below, its UI effect is as below picture shown. As you can see, I set Direction=90, so the picture shows that the shadow focuses more on 90 degree direction. But I hope to make the shadow effect equal in any direction.

Any advise?

<Border CornerRadius="30" Width="254" Height="50" Background="White">
    <Border.Effect>
        <DropShadowEffect
            ShadowDepth="2"
            Direction="90"
            Color="Black"
            Opacity="0.2"
            BlurRadius="18"/>
    </Border.Effect>
</Border>

enter image description here


Solution

  • You should set the ShadowDepth=0. After this you can then remove the angle attribute and get the desired result:

                    <Border Margin="5" CornerRadius="30" Width="254" Height="50" Background="White">
                        <Border.Effect>
                            <DropShadowEffect
                                ShadowDepth="0"
                                Color="Black"
                                Opacity="0.5"
                                BlurRadius="18"/>
                        </Border.Effect>
                    </Border>
    

    enter image description here