SIGN UP MEMBER LOGIN:    
ARTICLE

Drop Shadow Effect in WPF

Posted by Nipun Tomar Articles | WPF with C# March 03, 2011
Here you will learn WPF Drop Shadow Effect in .NET.
Reader Level:

If you want to apply the drop shadow effect to your UI Element:

Create a System.Windows.Media.Effects.DropShadowBitmapEffect element, and assign it to the BitmapEffect property of the element you want to have a shadow. Use the Color property of the DropShadowBitmapEffect element to define the color of the shadow and the ShadowDepth property to define the size of the shadow on the target element.

  • Open a new project in Visual Studio 2010 and named it as "DropShadowEffects".

    WPF1.gif
     
  • Draw an Ellipse of height= width=150.

    WPF2.gif
     
  • Fill the ellipse with an Image:

    <Ellipse.Fill>
         <ImageBrush ImageSource="bithday5.bmp" />           
    </Ellipse.Fill>

    WPF3.gif
     
  • Now Write code as under to fill the Ellipse with an Image and to show the Shadow effect:

    <Window x:Class="DropShadowEffect.MainWindow"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"|       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width
    ="525">

             <Ellipse Height="150" Width="150" Stroke="Black" StrokeThickness="1">
                <Ellipse.BitmapEffect>
                    <DropShadowBitmapEffect Color="Black" Direction="-50"
                        ShadowDepth="40" Softness=".7" />
                </Ellipse.BitmapEffect>            <Ellipse.Fill>
                    <ImageBrush ImageSource="bithday5.bmp" />
                </Ellipse.Fill>
            </Ellipse>
    </
    Window>
     

  • So the Output would be :

    WPF4.gif


Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor