How to Add Shadow to a WPF Control

By Michael Detras

Add a shadow effect on your WPF control using a pixel shader.

Create a shadow effect on your control by using the Effect property. The following code snippet shows how to do this in XAML.

<Button
    x:Name="MyButton">
    <Button.Effect>
         
<DropShadowEffect/>
    </Button.Effect
>
</Button>

Doing this in C# code is also easy.

MyButton.Effect = new DropShadowEffect();

WPF pixel shader effects became available on .NET 3.5 SP1.

How to Add Shadow to a WPF Control  (2293 Views)