New to Telerik UI for WPF? Download free 30-day trial


Fields are a convenient way to show non-static data in the document. In this way, you could present different data to the end-user without actually changing the document content.

This topic contains the following sections:

Field Types

In the model of RadDocument, the base class for all fields is CodeBasedField. It is an abstract class that can be inherited from.

All the supported field codes and switches for them are listed in the Supported Fields topic.

Display Modes

Fields normally have two modes – Code and Result. When in code mode, they appear as {<FieldTypeName> [<field parameter>] [<switch> <switch parameter>]}.

For instance, Page Fields appear as { PAGE }, Merge Fields as { MERGEFIELD FirstName } or { MERGEFIELD FirstName \b "text that will appear before the merge field if it is not empty" }.

In result mode, all fields get evaluated depending on some conditions – the place in the document where they appear in the case of page fields, the current mail merge record for merge fields, etc.

MergeFields have one additional mode – DisplayName that shows the property path they use in brackets of the type <<[PropertyPathHere]>>. Furthermore, there are specific methods and commands of the editor that change the display mode of merge fields or even remove them from the document altogether, replacing them with the ResultFragment. More information on this topic can be found in the Mail Merge article.

Inserting a Field

Inserting any type of field in the document of an editor can be done with the InsertField() method.

Insert a page field:

this.radRichTextBox.InsertField(new PageField()); 

Updating a Field

Update of a field can be triggered from the context menu or using the UpdateField() method by passing the corresponding FieldRangeStart of the field as a parameter.

Update a field:


Updating all Fields

You can update all fields in the document with the UpdateAllFields() method of RadRichTextBox. The method is optimized to perform better than updating fields one by one using the Update method.

Correctly updating all fields in a document works in almost all cases, but it’s not always possible as there are multiple dependencies between the fields. You can influence the way UpdateAllFields is executed by registering additional update information for specific field types.

See Also

In this article