.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Customize TextBox Control in Silverlight Application

Posted By:Diptimaya Patra       Posted Date: March 25, 2010    Points: 25    Category: Silverlight    URL: http://www.dotnetspark.com  

Customize TextBox Control in Silverlight Application. In this sample I will show you how you can change the Text ForeGround and the CaretBrush.
 

Introduction

In my previous article "Customizing Slider Control In Silverlight 3" we saw some customization of Slider control. In this article we will see how can we customize our common TextBox Control. In this sample I will show you how you can change the Text ForeGround and the CaretBrush.

Creating Silverlight 3 Application

Open up Blend 3 and create a Silverlight 3 Application.

1.gif

  1. Go ahead and draw a TextBox into your Grid and make it larger so that you can see the changes clearly.

    2.gif

    I have changed the Back ground color as black and the Foreground as Linear Gradient Brush. Here is the Xaml code for your reference.

     
      
      
      
      
      
      
      
      
    


    3.gif


    Now we will change the CaretBrush, Caret is nothing but a vertical line. When you type something in the TextBox one thin line used to blink. The default color for it is Black. Now we will modify to match to our Foreground Text.
     
  2. Select the CaretBrush and change the Brush to LinearGradient Brush.

    4.gif

    Of course you can't see the Caret while you design. So run your application and now try to type something in the TextBox. You will be able to see the Caret changed to its Linear Gradient Color that we have provided.

    5.gif

    Here is the XAML code for your reference.
    
      
      
      
      
      
      
      
    

That's it you have successfully customized your TextBox control.

You can also download the sample code used in the above example.

Enjoy Coding!
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend