Class RichTextBox
Represents a rich text control that supports formatted text, hyperlinks, inline images, and other rich content.
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
[TemplatePart(Name = "ContentElement", Type = typeof(FrameworkElement))]
public class RichTextBox : Control, IControl, IFrameworkElement, IUIElement, IDependencyObject
Constructors
| Improve this Doc View SourceRichTextBox()
Initializes a new instance of the RichTextBox class.
Declaration
public RichTextBox()
Fields
| Improve this Doc View SourceAcceptsReturnProperty
Identifies the AcceptsReturn dependency property.
Declaration
public static readonly DependencyProperty AcceptsReturnProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
AcceptsTabProperty
Identifies the AcceptsReturn dependency property.
Declaration
public static readonly DependencyProperty AcceptsTabProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
CaretBrushProperty
Identifies the CaretBrush dependency property.
Declaration
public static readonly DependencyProperty CaretBrushProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
IsReadOnlyProperty
Identifies the IsReadOnly dependency property.
Declaration
public static readonly DependencyProperty IsReadOnlyProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
IsSpellCheckEnabledProperty
Identifies the IsSpellCheckEnabled dependency property.
Declaration
public static readonly DependencyProperty IsSpellCheckEnabledProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
LineHeightProperty
Identifies the LineHeight dependency property.
Declaration
public static readonly DependencyProperty LineHeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
LineStackingStrategyProperty
Identifies the LineStackingStrategy dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty LineStackingStrategyProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
TextAlignmentProperty
Identifies the TextAlignment dependency property.
Declaration
public static readonly DependencyProperty TextAlignmentProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
TextWrappingProperty
Identifies the TextWrapping dependency property.
Declaration
public static readonly DependencyProperty TextWrappingProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceAcceptsReturn
Gets or sets a value that determines whether the RichTextBox allows and displays the newline or return characters when the ENTER or RETURN keys are pressed.
Declaration
public bool AcceptsReturn { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the RichTextBox allows newline characters; otherwise, false. The default is true. |
AcceptsTab
Gets or sets a value that determines whether the RichTextBox allows and displays the tabulation character when the TAB key is pressed.
Declaration
public bool AcceptsTab { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the RichTextBox allows tabulation character; otherwise, false. The default is false. |
BaselineOffset
Gets a value that represents the offset in pixels from the top of the content to the baseline of the first paragraph. The baseline of the paragraph is the baseline of the first line in it.
Declaration
[NotImplemented]
public double BaselineOffset { get; }
Property Value
Type | Description |
---|---|
System.Double | The computed baseline for the first paragraph, or 0 if the RichTextBox is empty. |
Blocks
Gets the contents of the RichTextBox.
Declaration
public BlockCollection Blocks { get; }
Property Value
Type | Description |
---|---|
BlockCollection | A BlockCollection that contains the contents of the RichTextBox. |
CaretBrush
Gets or sets the brush that is used to render the vertical bar that indicates the insertion point.
Declaration
public Brush CaretBrush { get; set; }
Property Value
Type | Description |
---|---|
Brush | A brush that is used to render the vertical bar that indicates the insertion point. |
ContentEnd
Gets a TextPointer that indicates the end of content in the RichTextBox.
Declaration
public TextPointer ContentEnd { get; }
Property Value
Type | Description |
---|---|
TextPointer | A TextPointer that indicates the end of content in the RichTextBox. |
ContentStart
Gets a TextPointer that indicates the start of content in the RichTextBox.
Declaration
public TextPointer ContentStart { get; }
Property Value
Type | Description |
---|---|
TextPointer | A TextPointer that indicates the start of content in the RichTextBox. |
HorizontalScrollBarVisibility
Gets or sets the visibility of the horizontal scroll bar.
Declaration
public ScrollBarVisibility HorizontalScrollBarVisibility { get; set; }
Property Value
Type | Description |
---|---|
ScrollBarVisibility | The visibility of the horizontal scroll bar. The default is Hidden. |
IsReadOnly
Gets or sets a value that determines whether the user can change the text in the RichTextBox. The default is false.
Declaration
public bool IsReadOnly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsSpellCheckEnabled
Gets or sets a value that specifies whether the RichTextBox input interacts with a spell check engine.
Declaration
public bool IsSpellCheckEnabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the RichTextBox input interacts with a spell check engine; otherwise, false. The default is false. |
LineHeight
Gets or sets the height of each line of content.
Declaration
public double LineHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The height of each line in pixels. A value of 0 indicates that the line height is determined automatically from the current font characteristics. The default is 0. |
LineStackingStrategy
Gets or sets a value that indicates how a line box is determined for each line of text in the RichTextBox.
Declaration
[NotImplemented]
public LineStackingStrategy LineStackingStrategy { get; set; }
Property Value
Type | Description |
---|---|
LineStackingStrategy | A value that indicates how a line box is determined for each line of text in the RichTextBox. The default is MaxHeight. |
Selection
Gets the TextSelection in the RichTextBox.
Declaration
public TextSelection Selection { get; }
Property Value
Type | Description |
---|---|
TextSelection | A TextSelection that represents the selected text in the RichTextBox. |
TextAlignment
Gets or sets how the text should be aligned in the RichTextBox.
Declaration
public TextAlignment TextAlignment { get; set; }
Property Value
Type | Description |
---|---|
TextAlignment | One of the TextAlignment enumeration values. The default is Left. |
TextWrapping
Gets or sets how text wrapping occurs if a line of text extends beyond the available width of the RichTextBox.
Declaration
public TextWrapping TextWrapping { get; set; }
Property Value
Type | Description |
---|---|
TextWrapping | One of the TextWrapping values. The default is Wrap. |
VerticalScrollBarVisibility
Gets or sets the visibility of the vertical scroll bar.
Declaration
public ScrollBarVisibility VerticalScrollBarVisibility { get; set; }
Property Value
Type | Description |
---|---|
ScrollBarVisibility | The visibility of the vertical scroll bar. The default is Auto. |
Xaml
Gets or sets a XAML representation of the content in the RichTextBox.
Declaration
public string Xaml { get; set; }
Property Value
Type | Description |
---|---|
System.String | A System.String object that is a XAML representation of the content in the RichTextBox. |
Methods
| Improve this Doc View SourceDeferRefresh()
Declaration
public IDisposable DeferRefresh()
Returns
Type | Description |
---|---|
System.IDisposable |
GetPositionFromPoint(Point)
Returns a TextPointer that indicates the closest insertion position for the specified point.
Declaration
[NotImplemented]
public TextPointer GetPositionFromPoint(Point point)
Parameters
Type | Name | Description |
---|---|---|
Point | point | A point in the coordinate space of the RichTextBox for which the closest insertion position is retrieved. |
Returns
Type | Description |
---|---|
TextPointer | A TextPointer that indicates the closest insertion position for the specified point. |
OnApplyTemplate()
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnCreateAutomationPeer()
Returns a RichTextBoxAutomationPeer for use by the Silverlight automation infrastructure.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
AutomationPeer | A RichTextBoxAutomationPeer for the RichTextBox object. |
Overrides
| Improve this Doc View SourceOnGotFocus(RoutedEventArgs)
Called before the GotFocus event occurs.
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnKeyDown(KeyEventArgs)
Called when the KeyDown event occurs.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnLostFocus(RoutedEventArgs)
Called before the LostFocus event occurs.
Declaration
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnMouseEnter(MouseEventArgs)
Called before the MouseEnter event occurs.
Declaration
protected override void OnMouseEnter(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnMouseLeave(MouseEventArgs)
Called before the MouseLeave event occurs.
Declaration
protected override void OnMouseLeave(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnMouseLeftButtonDown(MouseButtonEventArgs)
Called before the MouseLeftButtonDown event occurs.
Declaration
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseButtonEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnMouseLeftButtonUp(MouseButtonEventArgs)
Called before the MouseLeftButtonUp event occurs.
Declaration
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseButtonEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnTextInput(TextCompositionEventArgs)
Called before the TextInput event occurs.
Declaration
[NotImplemented]
protected override void OnTextInput(TextCompositionEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
TextCompositionEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceSelectAll()
Selects the entire contents in the RichTextBox.
Declaration
public void SelectAll()
Events
| Improve this Doc View SourceContentChanged
Occurs when the content changes in a RichTextBox.
Declaration
public event ContentChangedEventHandler ContentChanged
Event Type
Type | Description |
---|---|
ContentChangedEventHandler |
SelectionChanged
Occurs when the text selection has changed.
Declaration
public event RoutedEventHandler SelectionChanged
Event Type
Type | Description |
---|---|
RoutedEventHandler |