Version

Adding xamRichTextEditor to Your Page

Topic Overview

Purpose

This topic provides detailed instructions to help you get up and running as quickly as possible with the xamRichTextEditor ™.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic provides an overview of the features supported by the xamRichTextEditor control.

This topic explains the document’s content logical structure you can use to edit the contents in the xamRichTextEditor programmatically.

In this topic

This topic contains the following sections:

Adding xamRichTextEditor to Your Page

Introduction

This procedure explains step by step the operations necessary for adding xamRichTextEditor to your page.

Preview

The following screenshot is a preview of the result.

xamRichTextEditor Adding01.png

Steps

The following steps demonstrate how to add xamRichTextEditor to your page.

1. NuGet package references

Add the following NuGet package reference to your project:

  • Infragistics.WPF.RichTextEditor

For more information on setting up the NuGet feed and adding NuGet packages, you can take a look at the following documentation: NuGet Feeds.

2. Serialization providers NuGet package references

If you need to export or import external rich content add the following additional NuGet package references:

  • Infragistics.WPF.RichTextDocument.Html

  • Infragistics.WPF.RichTextDocument.Rtf

  • Infragistics.WPF.RichTextDocument.Word

3. Namespaces

Add the following namespaces:

In XAML:

xmlns:ig="http://schemas.infragistics.com/xaml"

In C#:

using Infragistics.Controls.Editors;
using Infragistics.Documents.RichText;

In Visual Basic:

Imports Infragistics.Controls.Editors
Imports Infragistics.Documents.RichText

4. Create xamRichTextEditor

Create and put the xamRichTextEditor on your page:

In XAML:

<ig:XamRichTextEditor x:Name="xamRichTextEditor1">
</ig:XamRichTextEditor>

5. Add serialization providers (optional)

Optionally, If you need to export or import external rich content add the following:

In XAML:

<ig:XamRichTextEditor.ClipboardSerializationProviders>
    <ig:RtfSerializationProvider />
    <ig:WordSerializationProvider />
</ig:XamRichTextEditor.ClipboardSerializationProviders>

In C#:

this.xamRichTextEditor1.ClipboardSerializationProviders.
    Add(RtfSerializationProvider.Instance);
this.xamRichTextEditor1.ClipboardSerializationProviders.
    Add(WordSerializationProvider.Instance);

In Visual Basic:

Me.xamRichTextEditor1.ClipboardSerializationProviders.
    Add(RtfSerializationProvider.Instance)
Me.xamRichTextEditor1.ClipboardSerializationProviders.
    Add(WordSerializationProvider.Instance)

6. Create document (optional)

Optionally, create the RichTextDocument and set it to the xamRichTextEditor ’s Document property:

In XAML:

<ig:XamRichTextEditor.Document>
    <ig:RichTextDocument />
</ig:XamRichTextEditor.Document>

In C#:

RichTextDocument doc = new RichTextDocument();
this.xamRichTextEditor1.Document = doc;

In Visual Basic:

Dim doc As New RichTextDocument()
Me.xamRichTextEditor1.Document = doc

7. Add a text (optional)

Optionally, the following code adds a plain text paragraph to the document:

In C#:

RichTextDocument doc = this.xamRichTextEditor1.Document;
ParagraphNode pn = new ParagraphNode();
pn.SetText("Some text");
doc.RootNode.Body.ChildNodes.Add(pn);

In Visual Basic:

Dim doc As RichTextDocument = Me.xamRichTextEditor1.Document
Dim pn As New ParagraphNode()
pn.SetText("Some text")
doc.RootNode.Body.ChildNodes.Add(pn)
Note
Note

The text above will appear in the second paragraph of the document because, by default, newly created documents contain an empty first paragraph.

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

The topics in this section provide additional information about xamRichTextEditor configuring.

The topics in this section provide deep knowledge on how to programmatically manage the xamRichTextEditor .