

'Declaration<LocalizabilityAttribute(LocalizationCategory.Inherit)> <ContentPropertyAttribute("Document")> <TemplatePartAttribute(Name="PART_ContentHost", Type=System.Windows.FrameworkElement)> <StyleTypedPropertyAttribute(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)> <XmlLangPropertyAttribute("Language")> <UsableDuringInitializationAttribute(True)> <RuntimeNamePropertyAttribute("Name")> <UidPropertyAttribute("Uid")> <TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)> <NameScopePropertyAttribute("NameScope", System.Windows.NameScope)> Public Class RichTextBox Inherits System.Windows.Controls.RichTextBox
'UsageDim instance As RichTextBox
[Localizability(LocalizationCategory.Inherit)] [ContentProperty("Document")] [TemplatePart(Name="PART_ContentHost", Type=System.Windows.FrameworkElement)] [StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)] [XmlLangProperty("Language")] [UsableDuringInitialization(true)] [RuntimeNameProperty("Name")] [UidProperty("Uid")] [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)] [NameScopeProperty("NameScope", System.Windows.NameScope)] public class RichTextBox : System.Windows.Controls.RichTextBox
The RichTextBox control has a Text dependency property that allows a user to data bind content to the RichTextBox.Document property.
The RichTextBox control uses text formatters to allow a user to format the content of the RichTextBox control into any format of their choice. Three text formatters are included: PlainTextFormatter, RtfFormatter, and XamlFormatter. The RtfFormatter is the default text formatter. A user can create their own custom text formatter by creating a class that inherits from ITextFormatter and implementing its members accordlingly.
When data binding to the Text property, you must use the Text Formatter that matches the format of the underlying data. If your data is in RTF, you must use RTFFormatter; if your data is in plain text, you must use the PlainTextFormatter; if your data is XML, you must use XmlFormatter.
When using the RichTextBox with buttons to change the styles of your text such as bold, italics, etc., you will notice that the Text is not updated until the control loses focus. Therefore when you leave focus on the RichTextBox and start manipulating test with buttons, those changes will not be propogated properly. This is because by default, the source is not update until the RichTextBox control loses focus. To enable this behavior you must set the UpdateSourceTrigger to PropertyChanged on your Text property binding. This will force any change to the text to be updated through data binding to the underlying data source.
Custom text formatters can be used by implementing the ITextFormatter interface (see ITextFormatter for details and examples).
<xctk:RichTextBox x:Name="_richTextBox" Grid.Row="1" Margin="10" BorderBrush="Gray" Padding="10" Text="{Binding Notes}" ScrollViewer.VerticalScrollBarVisibility="Auto"> <xctk:RichTextBox.TextFormatter> <xctk:PlainTextFormatter /> </xctk:RichTextBox.TextFormatter> </xctk:RichTextBox>
<xctk:RichTextBox x:Name="_richTextBox" Grid.Row="1" Margin="10" BorderBrush="Gray" Padding="10" Text="{Binding Notes}" ScrollViewer.VerticalScrollBarVisibility="Auto"> <xctk:RichTextBox.TextFormatter> <xctk:RtfFormatter /> </xctk:RichTextBox.TextFormatter> </xctk:RichTextBox>
<xctk:RichTextBox x:Name="_richTextBox" Grid.Row="1" Margin="10" BorderBrush="Gray" Padding="10" Text="{Binding Notes}" ScrollViewer.VerticalScrollBarVisibility="Auto"> <xctk:RichTextBox.TextFormatter> <xctk:XamlFormatter /> </xctk:RichTextBox.TextFormatter> </xctk:RichTextBox>
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
System.Windows.Controls.Primitives.TextBoxBase
System.Windows.Controls.RichTextBox
Xceed.Wpf.Toolkit.RichTextBox
| Name | Description | |
|---|---|---|
![]() | RichTextBox Constructor | Overloaded. Initializes a new instance of the RichTextBox class. |
| Name | Description | |
|---|---|---|
![]() ![]() | TextFormatterProperty | Identifies the TextFormatter dependency property. |
![]() ![]() | TextProperty | Identifies the Text dependency property. |
| Name | Description | |
|---|---|---|
![]() | FindLogicalAncestor<T> | Finds the logical ancenster |
![]() | FindLogicalAncestorsAndSelf | |
![]() | FindLogicalChildren<T> | Find the logical children. |
![]() | FindVisualAncestor<T> | Finds the visual ancestor. |
![]() | FindVisualChildren<T> | Finds the visual children. |
![]() | FindVisualTreeRoot | Finds the visual tree root. |
![]() | ShowDialog | Overloaded. |
.NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.
.NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.