Articles in this section
Category / Section

How to create rich text editor in WPF RichTextBox (SfRichTextBoxAdv)?

2 mins read

WPF RichTextBox (SfRichTextBoxAdv) control, a.k.a. WYSIWYG rich text editor, allows you to view, edit, format, and print rich text content including text, images, hyperlink and more. It helps you create a rich text editor in C#. It also provides all the common Word processing features and helps you add a comprehensive word processor to your WPF applications using a familiar Microsoft Word-like ribbon interface for your end users.

Steps to create rich text editor in C#:

  1. Create a new WPF application project.

Create WPF application in Visual Studio

 

  1. Install the Syncfusion.SfRichTextBoxAdv.WPF NuGet package as a reference to your WPF application from NuGet.org.

Add RichTextBox control NuGet package reference to the project

 

  1. Include the following namespaces in the MainWindow.xaml file.

XAML

xmlns:RichTextBoxAdv="clr-namespace:Syncfusion.Windows.Controls.RichTextBoxAdv;assembly=Syncfusion.SfRichTextBoxAdv.Wpf"

C#

using Syncfusion.Windows.Controls.RichTextBoxAdv;

 

  1. Add the following code to create rich text editor

XAML

<SfRichTextBox:SfRichTextBoxAdv x:Name="richTextBoxAdv" LayoutType="Continuous"/>

C#

SfRichTextBoxAdv richTextBoxAdv = new SfRichTextBoxAdv();
richTextBoxAdv.LayoutType = LayoutType.Continuous;

 

 

  1. Add below namespace for adding Toolbar. Here we have used Syncfusion® ToolBarAdv control.

XAML

xmlns:SfTools="http://schemas.syncfusion.com/wpf"

C#

using Syncfusion.Windows.Tools.Controls;

The below code snippet will demonstrate how to add Bold formatting button in Toolbar and binding it with rich text editor control. Similarly, you can add for other formatting properties.

XAML

<SfTools:ToolBarAdv>
      <SfTools:ButtonAdv IsCheckable="True" IsChecked="{Binding ElementName=richTextBoxAdv,Path=Selection.CharacterFormat.Bold,Mode=TwoWay}"/>
</SfTools:ToolBarAdv>

 

The rich text editor created by using Syncfusion WPF RichTextBox control.

View sample in GitHub.

Take a moment to peruse the documentation, where you can find basic information about rich text editor along with features like edit, import, export and print rich text content including text, images, table and hyperlink. find and replace text, clipboard operations undo and redo options with code examples.

 

Explore more about the rich set of Syncfusion® richtextbox features.

 

Note:

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message.

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied