Tuesday, November 17, 2015

Drop Shadow example in WPF

2:28 AMTuesday, November 17, 2015
In this article, I will show you, How to create Shadow of controls. Through this, we can show 3d view of control. First of all, I will apply this style on manually created designs like Ellipse, Rectangle etc. After that I will apply same things on controls. So, add a new window in the project. Add this code in between the <grid> ...</grid> section of xaml file.

 <Rectangle Height="150" Width="150" Stroke="Black" StrokeThickness="2">
                <DropShadowBitmapEffect Color="Black" Direction="-50" ShadowDepth="40" Softness=".8"/>
                <ImageBrush ImageSource="apple.png"/>

BitmapEffect creates the shadow effect behind the object. In the above-mentioned code we have Direction attribute. With the help of Direction attribute we can show shadow of control at user defined position. 

<Button Width="150" Margin="71,167,71,59">
                <DropShadowBitmapEffect Color="Black" Direction="-50" ShadowDepth="40" Softness=".7"/>
            <Image Source="apple.png" Stretch="Fill"/>

Code generates the following output

Drop Shadow example in WPF

Protected by Copyscape Online Copyright Protection Software


Post a Comment

Toggle Footer