Rich Text Area in Silverlight 4 Using VS 2010 Beta – Part I



In this article we will see Rich Text Area, which came with Silverlight 4.

Creating Silverlight Project

Fire up Visual Studio 2010 and create a new Silverlight Application Project. Name it as RichTextBoxSample.

The following design will explain about the sample application.

As you see above we have several Tool Buttons to achieve some of the Rich Text Area functionalities. In this article we will achieve the following and rest would be achieved in the Part II of this article.

  1. Bold
  2. Underline
  3. Italics
  4. Font Change
  5. Font Size Change

We would add ComboBox items for Font Names and Font Sizes.

For Font Names the ComboBox Items are added in XAML. Following XAML code is for your reference.

Now we will add codes to the Buttons Bold, Underline and Italics as follows.

Now on the SelectionChanged event handler of FontNames and FontSizes ComboBox we will write the below code.

Now we are ready to run the application for the above tools in Rich Text Area.

Now we will apply the above styles in the Rich Text Area.

In Part II we will see other functionalities and new too.

Hope this article helps. J