Before Silverlight 3, you had to do perform some less-than-ideal tricks to achieve a drop shadow effect on your text. In fact, the most decent trick I could find had to rely on the TextBox control and not the TextBlock control since you cannot re-template a TextBlock control. But even that technique was not optimal since you couldn’t get a truly smooth shadow.
Well, that was then an this is now! In Silverlight 3, you can do the following:
<TextBlock
Foreground="White"
Text="Lorem ipsum dolor sit amet"
FontSize="50"
FontWeight="Bold">
<TextBlock.Effect>
<DropShadowEffect Color="Black" BlurRadius="5" />
</TextBlock.Effect>
</TextBlock>
And Presto!
Just look how much easier it is to read the first line over the second line! Also notice that there are a few other properties that you can specify if you desire:
- BlurRadius – Controls the radius of the blur. A larger number would indicate a softer shadow.
- Color – The color of the shadow (or glow if the color is appropriate).
- Direction – The angle of the drop shadow (315 degrees is the default). The angle increases in a counter-clockwise direction.
- Opacity – A double value indicating the percentage of opaqueness.
- ShadowDepth – Indicates how far the shadow should appear below the text. This property is used to control how far away the object appears from it’s backing surface.
Of course, you can apply effects to any UIElement, it just so happens that drop shadows on text is really, really, useful!