Recommended

Skip Navigation LinksHome / Tips / View Tip

How to style the caret in Silverlight 3

+ Add to SilverlightShow Favorites
1 comments   /   posted by Nikolay Raychev on Mar 25, 2009
(1 votes)
Categories: General
It's very easy to style the caret in Silverlight 3. Look at that huge TextBox with a caret in the rainbow colors:



You just need to set the CaretBrush property:

<TextBox FontSize="50" Width="100" Height="80">  
    <TextBox.RenderTransform> 
        <ScaleTransform ScaleX="6" ScaleY="1"/>  
    </TextBox.RenderTransform> 
    <TextBox.CaretBrush>
        <LinearGradientBrush x:Name="backgroundLinearGradientBrush"
            MappingMode="RelativeToBoundingBox"
                StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="Red" Offset="0" />
                <GradientStop Color="Orange" Offset="0.167" />
                <GradientStop Color="Yellow" Offset="0.333" />
                <GradientStop Color="Green" Offset="0.5"/>
                <GradientStop Color="Blue" Offset="0.667" />
                <GradientStop Color="Indigo" Offset="0.833" />
                <GradientStop Color="Violet" Offset="1" />
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
    </TextBox.CaretBrush> 
</TextBox> 

You can use any Silverlight supported Brush.

Share


Comments

Comments RSS RSS
  • RE: How to style the caret in Silverlight 3  

    posted by apreski on Aug 24, 2009 15:33
    OMG what a wonderfull and perfect and so usefull tric ! i won't sleep for three days.

Add Comment

 
 

   
  
  
   
Please add 1 and 1 and type the answer here:

Help us make SilverlightShow even better and win a free t-shirt. Whether you'd like to suggest a change in the structure, content organization, section layout or any other aspect of SilverlightShow appearance - we'd love to hear from you! Need a material (article, tutorial, or other) on a specific topic? Let us know and SilverlightShow content authors will work to have that prepared for you. (hide this)