Adding Reflection to the Text

No.of Views844
Bookmarked0 times
Downloads 
Votes0
By  NikhilJohari   On  01 Aug 2010 07:08:14
Tag : Silver Light and XAML , Miscellaneous Controls
Adding Reflection to the Text in Silver Light
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

You can make your text elements look more attractive by adding various special effects to the text.

One such effect that can be implemented on the TextBlock element is Reflection you can create a new TextBlock to contain the reflection of the text written in the original TextBlock.You can then place the new TextBlock under the original TextBlock.

The reflection effect can be created by transforming the desired element by using the RenderTransform property of the element.

Code

Consider the following code snippet:

<Canvas>
<TextBlock Width=”56” Canvas.Left=”50” Canvas.Top= “0” Text=”Reflection Text” FontWeight = “Bold” FontSize= “16” Foreground=”Red”/>

<TextBlock Width=”67” Canvas.Left=”50” Canvas.Top= “53” FontSize=”16” FontWeight = “Bold” Text=”Reflection Text” Foreground=”LightBlue”/>
                   <TextBlock.RenderTransform>
       <ScaleTransform ScaleY = “-2”/>
</TextBlock.RenderTransform>
</TextBlock>
</Canvas>

Explanation

The preceding code snippet creates two TextBlocks.The first TextBlock is created to display the actual text, whereas the second TextBlock is created to display the reflection of the text contained in the first TextBlock. The ScaleTransform tag scale the Y axis of the second TextBlock with a negative value to invert the text contained in it.

The following figure shows the output of the preceding code snippet.

Output

Image Loading

That's all enjoy the code snippet.

 
Sign Up to vote for this article
 
About Author
 
NikhilJohari
Occupation-
Company-
Member Type-Senior
Location-India
Joined date-15 Aug 2009
Home Page-http://fast-get.com
Blog Page-http://dotnetask.blog.co.in
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top