Show / Hide Table of Contents

Class RichTextBox

Represents a rich text control that supports formatted text, hyperlinks, inline images, and other rich content.

Inheritance
System.Object
DependencyObject
UIElement
FrameworkElement
Control
RichTextBox
Inherited Members
Control.EnableBaseControlHandlingOfVisualStates
Control.ManageIsEnabled(Boolean)
Control.Background
Control.BackgroundProperty
Control.BorderBrush
Control.BorderBrushProperty
Control.BorderThickness
Control.BorderThicknessProperty
Control.FontWeight
Control.FontWeightProperty
Control.FontStyle
Control.FontStyleProperty
Control.Foreground
Control.ForegroundProperty
Control.FontFamily
Control.FontFamilyProperty
Control.FontSize
Control.FontSizeProperty
Control.TextDecorations
Control.TextDecorationsProperty
Control.Padding
Control.PaddingProperty
Control.HorizontalContentAlignment
Control.HorizontalContentAlignmentProperty
Control.VerticalContentAlignment
Control.VerticalContentAlignmentProperty
Control.TabIndex
Control.TabIndexProperty
Control.IsTabStop
Control.IsTabStopProperty
Control.TabNavigation
Control.TabNavigationProperty
Control.Template
Control.TemplateProperty
Control.ApplyTemplate()
Control.GetTemplateChild(String)
Control.Focus()
Control.HandlesScrolling
Control.CreateDomElement(Object, Object)
Control.CharacterSpacingProperty
Control.CharacterSpacing
Control.FontStretchProperty
Control.FontStretch
Control.OnDrop(DragEventArgs)
Control.OnDragEnter(DragEventArgs)
Control.OnDragLeave(DragEventArgs)
Control.OnTextInputUpdate(TextCompositionEventArgs)
Control.MeasureOverride(Size)
Control.ArrangeOverride(Size)
FrameworkElement.LayoutUpdated
FrameworkElement.SizeChanged
FrameworkElement.ResourceLookupMode
FrameworkElement.StyleProperty
FrameworkElement.Style
FrameworkElement.DefaultStyleKeyProperty
FrameworkElement.DefaultStyleKey
FrameworkElement.OverridesDefaultStyleProperty
FrameworkElement.OverridesDefaultStyle
FrameworkElement.OnVisualParentChanged(DependencyObject)
FrameworkElement.VisualChildrenCount
FrameworkElement.GetVisualChild(Int32)
FrameworkElement.Parent
FrameworkElement.AddLogicalChild(Object)
FrameworkElement.RemoveLogicalChild(Object)
FrameworkElement.LogicalChildren
FrameworkElement.TemplatedParent
FrameworkElement.Resources
FrameworkElement.IsLoaded
FrameworkElement.SetBinding(DependencyProperty, BindingBase)
FrameworkElement.SetBinding(DependencyProperty, Binding)
FrameworkElement.GetBindingExpression(DependencyProperty)
FrameworkElement.Cursor
FrameworkElement.CursorProperty
FrameworkElement.FindName(String)
FrameworkElement.Name
FrameworkElement.NameProperty
FrameworkElement.DataContext
FrameworkElement.DataContextProperty
FrameworkElement.DataContextChanged
FrameworkElement.Triggers
FrameworkElement.FlowDirectionProperty
FrameworkElement.FlowDirection
FrameworkElement.LanguageProperty
FrameworkElement.Language
FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs)
FrameworkElement.Tag
FrameworkElement.TagProperty
FrameworkElement.LoadedEvent
FrameworkElement.Loaded
FrameworkElement.Unloaded
FrameworkElement.BindingValidationError
FrameworkElement.ContextMenuProperty
FrameworkElement.ContextMenu
FrameworkElement.ContextMenuOpening
FrameworkElement.ToolTipProperty
FrameworkElement.ToolTip
FrameworkElement.INTERNAL_OnDetachedFromVisualTree()
FrameworkElement.INTERNAL_OnAttachedToVisualTree()
FrameworkElement.Height
FrameworkElement.HeightProperty
FrameworkElement.Width
FrameworkElement.WidthProperty
FrameworkElement.HorizontalAlignment
FrameworkElement.HorizontalAlignmentProperty
FrameworkElement.VerticalAlignment
FrameworkElement.VerticalAlignmentProperty
FrameworkElement.Margin
FrameworkElement.MarginProperty
FrameworkElement.MinHeight
FrameworkElement.MinHeightProperty
FrameworkElement.MinWidth
FrameworkElement.MinWidthProperty
FrameworkElement.MaxHeight
FrameworkElement.MaxHeightProperty
FrameworkElement.MaxWidth
FrameworkElement.MaxWidthProperty
FrameworkElement.ActualWidthProperty
FrameworkElement.ActualWidth
FrameworkElement.ActualHeightProperty
FrameworkElement.ActualHeight
UIElement.TransformToVisual(UIElement)
UIElement.RenderSize
UIElement.DesiredSize
UIElement.InvalidateMeasure()
UIElement.InvalidateArrange()
UIElement.Measure(Size)
UIElement.Arrange(Rect)
UIElement.UpdateLayout()
UIElement.DragEnter
UIElement.DragLeave
UIElement.Drop
UIElement.DragOver
UIElement.CacheMode
UIElement.CacheModeProperty
UIElement.Projection
UIElement.ProjectionProperty
UIElement.VisualParent
UIElement.AddVisualChild(UIElement)
UIElement.RemoveVisualChild(UIElement)
UIElement.OnVisualChildrenChanged(DependencyObject, DependencyObject)
UIElement.XamlSourcePath
UIElement.ClipToBounds
UIElement.ClipToBoundsProperty
UIElement.ClipProperty
UIElement.Clip
UIElement.IsEnabledProperty
UIElement.IsEnabled
UIElement.IsEnabledChanged
UIElement.EffectProperty
UIElement.Effect
UIElement.RenderTransformProperty
UIElement.RenderTransform
UIElement.RenderTransformOriginProperty
UIElement.RenderTransformOrigin
UIElement.UseLayoutRounding
UIElement.UseLayoutRoundingProperty
UIElement.Visibility
UIElement.VisibilityProperty
UIElement.IsVisibleProperty
UIElement.IsVisible
UIElement.IsVisibleChanged
UIElement.OpacityProperty
UIElement.Opacity
UIElement.OpacityMaskProperty
UIElement.OpacityMask
UIElement.IsHitTestVisible
UIElement.IsHitTestVisibleProperty
UIElement.AllowDrop
UIElement.AllowDropProperty
UIElement.CaptureMouse()
UIElement.IsMouseCaptured
UIElement.ReleaseMouseCapture()
UIElement.AllowScrollOnTouchMove
UIElement.AllowScrollOnTouchMoveProperty
UIElement.AddHandler(RoutedEvent, Delegate, Boolean)
UIElement.RemoveHandler(RoutedEvent, Delegate)
UIElement.MouseMoveEvent
UIElement.MouseMove
UIElement.OnMouseMove(MouseEventArgs)
UIElement.MouseLeftButtonDownEvent
UIElement.MouseLeftButtonDown
UIElement.MouseRightButtonDownEvent
UIElement.MouseRightButtonDown
UIElement.OnMouseRightButtonDown(MouseButtonEventArgs)
UIElement.MouseWheelEvent
UIElement.MouseWheel
UIElement.OnMouseWheel(MouseWheelEventArgs)
UIElement.MouseLeftButtonUpEvent
UIElement.MouseLeftButtonUp
UIElement.MouseEnterEvent
UIElement.MouseEnter
UIElement.MouseLeaveEvent
UIElement.MouseLeave
UIElement.TextInputStartEvent
UIElement.TextInputStart
UIElement.OnTextInputStart(TextCompositionEventArgs)
UIElement.TextInputEvent
UIElement.TextInput
UIElement.TextInputUpdateEvent
UIElement.TextInputUpdate
UIElement.TappedEvent
UIElement.Tapped
UIElement.OnTapped(TappedRoutedEventArgs)
UIElement.MouseRightButtonUpEvent
UIElement.MouseRightButtonUp
UIElement.OnMouseRightButtonUp(MouseButtonEventArgs)
UIElement.KeyDownEvent
UIElement.KeyDown
UIElement.KeyUpEvent
UIElement.KeyUp
UIElement.OnKeyUp(KeyEventArgs)
UIElement.GotFocusEvent
UIElement.GotFocus
UIElement.LostFocusEvent
UIElement.LostFocus
UIElement.LostMouseCapture
UIElement.OnLostMouseCapture(MouseEventArgs)
UIElement.INTERNAL_AttachToDomEvents()
UIElement.INTERNAL_DetachFromDomEvents()
DependencyObject.GetValue(DependencyProperty)
DependencyObject.SetCurrentValue(DependencyProperty, Object)
DependencyObject.ReadLocalValue(DependencyProperty)
DependencyObject.SetValue(DependencyProperty, Object)
DependencyObject.SetValue(DependencyPropertyKey, Object)
DependencyObject.CoerceValue(DependencyProperty)
DependencyObject.Dispatcher
DependencyObject.ClearValue(DependencyProperty)
DependencyObject.ClearValue(DependencyPropertyKey)
DependencyObject.CheckAccess()
DependencyObject.GetAnimationBaseValue(DependencyProperty)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

RichTextBox()

Initializes a new instance of the RichTextBox class.

Declaration
public RichTextBox()

Fields

| Improve this Doc View Source

AcceptsReturnProperty

Identifies the AcceptsReturn dependency property.

Declaration
public static readonly DependencyProperty AcceptsReturnProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

AcceptsTabProperty

Identifies the AcceptsReturn dependency property.

Declaration
public static readonly DependencyProperty AcceptsTabProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

CaretBrushProperty

Identifies the CaretBrush dependency property.

Declaration
public static readonly DependencyProperty CaretBrushProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

IsReadOnlyProperty

Identifies the IsReadOnly dependency property.

Declaration
public static readonly DependencyProperty IsReadOnlyProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

IsSpellCheckEnabledProperty

Identifies the IsSpellCheckEnabled dependency property.

Declaration
public static readonly DependencyProperty IsSpellCheckEnabledProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

LineHeightProperty

Identifies the LineHeight dependency property.

Declaration
public static readonly DependencyProperty LineHeightProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

LineStackingStrategyProperty

Identifies the LineStackingStrategy dependency property.

Declaration
[NotImplemented]
public static readonly DependencyProperty LineStackingStrategyProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

TextAlignmentProperty

Identifies the TextAlignment dependency property.

Declaration
public static readonly DependencyProperty TextAlignmentProperty
Field Value
Type Description
DependencyProperty
| Improve this Doc View Source

TextWrappingProperty

Identifies the TextWrapping dependency property.

Declaration
public static readonly DependencyProperty TextWrappingProperty
Field Value
Type Description
DependencyProperty

Properties

| Improve this Doc View Source

AcceptsReturn

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

DeferRefresh()

Declaration
public IDisposable DeferRefresh()
Returns
Type Description
System.IDisposable
| Improve this Doc View Source

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.

| Improve this Doc View Source

OnApplyTemplate()

Declaration
public override void OnApplyTemplate()
Overrides
Control.OnApplyTemplate()
| Improve this Doc View Source

OnCreateAutomationPeer()

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
UIElement.OnCreateAutomationPeer()
| Improve this Doc View Source

OnGotFocus(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
Control.OnGotFocus(RoutedEventArgs)
| Improve this Doc View Source

OnKeyDown(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
UIElement.OnKeyDown(KeyEventArgs)
| Improve this Doc View Source

OnLostFocus(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
Control.OnLostFocus(RoutedEventArgs)
| Improve this Doc View Source

OnMouseEnter(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
UIElement.OnMouseEnter(MouseEventArgs)
| Improve this Doc View Source

OnMouseLeave(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
UIElement.OnMouseLeave(MouseEventArgs)
| Improve this Doc View Source

OnMouseLeftButtonDown(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
UIElement.OnMouseLeftButtonDown(MouseButtonEventArgs)
| Improve this Doc View Source

OnMouseLeftButtonUp(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
UIElement.OnMouseLeftButtonUp(MouseButtonEventArgs)
| Improve this Doc View Source

OnTextInput(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
UIElement.OnTextInput(TextCompositionEventArgs)
| Improve this Doc View Source

SelectAll()

Selects the entire contents in the RichTextBox.

Declaration
public void SelectAll()

Events

| Improve this Doc View Source

ContentChanged

Occurs when the content changes in a RichTextBox.

Declaration
public event ContentChangedEventHandler ContentChanged
Event Type
Type Description
ContentChangedEventHandler
| Improve this Doc View Source

SelectionChanged

Occurs when the text selection has changed.

Declaration
public event RoutedEventHandler SelectionChanged
Event Type
Type Description
RoutedEventHandler

Extension Methods

DependencyObjectHelper.GetSelfAndAncestors(DependencyObject)
UIElementExtendedRoutedEventExtensions.AddHandler(UIElement, ExtendedRoutedEvent, Delegate, Boolean)
UIElementExtendedRoutedEventExtensions.RemoveHandler(UIElement, ExtendedRoutedEvent, Delegate)
VisualTreeExtensions.GetVisualAncestors(DependencyObject)
VisualTreeExtensions.GetVisualAncestorsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualChildren(DependencyObject)
VisualTreeExtensions.GetVisualChildrenAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualDescendants(DependencyObject)
VisualTreeExtensions.GetVisualDescendantsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualSiblings(DependencyObject)
VisualTreeExtensions.GetVisualSiblingsAndSelf(DependencyObject)
VisualTreeExtensions.GetBoundsRelativeTo(FrameworkElement, UIElement)
VisualTreeExtensions.InvokeOnLayoutUpdated(FrameworkElement, Action)
  • Improve this Doc
  • View Source