Apply shadow effect to text WPF in VB.NET

Here I am going to explain you how to give a shadow effect to text in WPF.
  • 3886

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.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.