[WPF] Rounded Window Drop Shadow Problem

Md. Niaz Mahmud 171 Reputation points
2021-07-19T22:08:12.44+00:00

Hi,

I have a WPF window in my project, where the window will have a corner radius of 26. Using Drop Shadow, there are square corners of the shadow which looks odd. I have used as following...

<Border BorderThickness="1" CornerRadius="26" > <Border.Effect> <DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" ShadowDepth="2" Color="#FCFCFC" /> </Border.Effect>

Is there any way so that the shadow becomes rounded as the window is???

116016-capture.png

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,780 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 85,371 Reputation points
    2021-07-20T02:25:04.887+00:00

    By setting a border around the main border, I get a rounded shadow :

    116066-wpf-rounded-shadow.jpg

    <Border BorderBrush="Transparent" BorderThickness="10" CornerRadius="25" Background="Transparent">  
                        <Border BorderBrush="Red" BorderThickness="4" CornerRadius="25" Name = "MainBorder">  
     <Border.Effect>   
        <DropShadowEffect BlurRadius="15" Direction ="-90" RenderingBias ="Quality" ShadowDepth ="2" Color ="Red" />  
    </Border.Effect>                          
                            <Border.Background>  
                                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">  
                                    <GradientStop Color="Yellow" Offset="0.0" />  
                                    <GradientStop Color="Red" Offset="0.25" />  
                                    <GradientStop Color="Blue" Offset="0.75" />  
                                    <GradientStop Color="LimeGreen" Offset="1.0" />  
                                </LinearGradientBrush>  
                            </Border.Background>  
                        </Border>  
       </Border>  
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.