adjust drop shadow size in WPF. shown in the image

908 Views Asked by At

enter image description here

I try to resize the drop shadow effect in WPF. But I did not find any answer.

2

There are 2 best solutions below

3
o_w On BEST ANSWER

You cannot set margin to your shadow, so you could "hide" another simple

Border behind your "real" Border.

Wrap them in a Grid that will hold both of them in the same place.

Set your margin on that Border, and set the shadow effect on it as well.

<Grid>
   <Border Margin="20,20,0,0">
       <Border.Effects>
          <DropShadowEffect />
       </Border.Effects/>
   </Border>
   <Border x:Name="YourOriginalBorder"/>
</Grid>
1
TimonYang On

Just add the Background property to the Border in the o_w's example to show the shadow, or use other controls as example, such as button.

<Grid>
    <Button Content="Button1" Width="150" Height="30">
        <Button.Effect>
            <DropShadowEffect BlurRadius="1" Color="Red" Direction="340" Opacity="10" ShadowDepth="30" RenderingBias="Quality" />
        </Button.Effect>
    </Button>
    <Button Content="Button1" Width="200" Height="40" />
</Grid>

enter image description here

I wanted to post a comment, but I just joined StackOverflow and I can’t do it yet :(.