RichTextArea Class
[Note: This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Represents a rich text editing control that supports formatted text, hyperlinks, inline images, and other rich content.
Assembly: System.Windows (in System.Windows.dll)
[TemplateVisualStateAttribute(Name = "Valid", GroupName = "ValidationStates")] [TemplateVisualStateAttribute(Name = "ReadOnly", GroupName = "CommonStates")] [TemplateVisualStateAttribute(Name = "InvalidFocused", GroupName = "ValidationStates")] [TemplatePartAttribute(Name = "ContentElement", Type = typeof(FrameworkElement))] [TemplateVisualStateAttribute(Name = "Normal", GroupName = "CommonStates")] [TemplateVisualStateAttribute(Name = "Disabled", GroupName = "CommonStates")] [ContentPropertyAttribute("Blocks", true)] [TemplateVisualStateAttribute(Name = "MouseOver", GroupName = "CommonStates")] [TemplateVisualStateAttribute(Name = "Unfocused", GroupName = "FocusStates")] [TemplateVisualStateAttribute(Name = "Focused", GroupName = "FocusStates")] [TemplateVisualStateAttribute(Name = "InvalidUnfocused", GroupName = "ValidationStates")] public class RichTextArea : Control
You can use the RichTextArea control to display, enter, and edit rich text. RichTextArea provides more advanced formatting features than the TextBox and TextBlock controls. You can apply character and paragraph formatting to the text in the RichTextArea. For example, you can apply Bold, Italic, and Underline to any portion of the text in the control.
The content property of RichTextArea is the Blocks property, which is based on the Paragraph element. Content can contain many types of elements including formatted text, hyperlinks, and images.
RichTextArea supports hyperlinks. You can use the Hyperlink element to display hyperlinks in a RichTextArea. You must set the IsReadOnly property of the RichTextArea to true for hyperlinks to work.
You can use the RichTextArea to display text with UI elements that are derived from UIElement, such as images. You can do this by using the InlineUIContainer.
RichTextArea has a read-only mode. You can enable read-only mode by setting the IsReadOnly property to true.
The following code shows how to create a RichTextArea with a paragraph and some bold text.
//A RichTextArea with intial content in it. 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(); myParagraph.Inlines.Add(myRun1); myParagraph.Inlines.Add(myBold); myParagraph.Inlines.Add(myRun2); // Add the paragraph to the RichTextArea. MyRTA.Blocks.Add(myParagraph); //Add the RichTextArea to the StackPanel. MySP.Children.Add(MyRTA); }
System.Windows.DependencyObject
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
System.Windows.Controls.RichTextArea
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.