- displaying hyperlinks
- displaying inline images or other UIElements like a Button
- Read-only mode
- Selection APIs
- Formatting text at run time
Creating a RichTextArea is simple, it is similar to creating any other control in Silverlight. You can set content in a RichTextArea using the Paragraph element (the content property itself is Blocks, which in turn is a collection of Paragraph elements).
Here’s some sample code that shows you how to create a RichTextArea with a paragraph and some bold text.
<Paragraph> A RichTextArea with <Bold>initial content</Bold> in it. </Paragraph>
Here’s the C# code, which does the same thing as the above xaml.
private void ContentRTA()
//Create a new RichTextArea with its VerticalScrollBarVisibility property set to Auto.
RichTextArea MyRTA = new RichTextArea();
MyRTA.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
// Create a Run of plain text and some bold text.
Run myRun1 = new Run();
myRun1.Text = "A RichTextArea with ";
Bold myBold = new Bold();
myBold.Inlines.Add("initial content ");
Run myRun2 = new Run();
myRun2.Text = "in it.";
// Create a paragraph and add the Run and Bold to it.
Paragraph myParagraph = new Paragraph();
// Add the paragraph to the RichTextArea.
//Add the RichTextArea to the StackPanel.