ARTICLE

Apply shadow effect to text in WPF

Posted by Sapna Articles | WPF using VB.NET October 01, 2010
Here I am going to explain you how to give a shadow effect to text in WPF.
 
Reader Level:

You can apply shadow effect to your text in WPF with the help of DropShadowEffect object. It allows you to create a variety of drop shadow effects for Windows Presentation Foundation (WPF) objects. See the below example which shows a drop shadow effect applied to text. In the following example, the shadow is a soft shadow, which means the shadow color blurs.

Text before Shadow effect

Welcome to vbdotnetheaven

The following code example shows how to create a shadow effect.

<Window x:Class="Window1"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
   <Canvas>
 
       <TextBlock Margin="3,0,3,13" FontSize="40" FontWeight="Bold">
     <TextBlock.Text>Welcome to vbdotnetheaven</TextBlock.Text>
      <DropShadowBitmapEffect ShadowDepth="20" Color="lightgreen" Softness="0"></DropShadowBitmapEffect>
     </TextBlock.BitmapEffect>
        </TextBlock>
   </Canvas>
</Window>

Text after Shadow effect

shadow.gif

Note:   You can control the width of a shadow by setting the ShadowDepth property and the softness, or blur, of a shadow by modifying the BlurRadius property whereas a value of 5.0 indicates a shadow width of 5 pixels and value of 0.0 indicates no blurring.

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Diagram
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.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Diagram
Become a Sponsor