# Cross-Reference

Cross-References represent fields that refer to a part of the document. When that part changes, these fields can be updated to reflect the change. You can have a Cross-Reference to a Caption, Heading or Bookmark.

You can insert a Cross-Reference from here:

![Rad Rich Text Box Features Cross Reference 01](https://www.telerik.com/products/wpf/documentation/assets/0b898b721352eb4188ffbf449923596c/radrichtextbox_features_cross_reference_01.png)

## Insert Cross-Reference

The dialog looks like this:

![Rad Rich Text Box Features Cross Reference 02](https://www.telerik.com/products/wpf/documentation/assets/388caf809fbf7787356a8ef6a386710e/radrichtextbox_features_cross_reference_02.png)

You can choose between 4 Reference types: **Figure**, **Table**, **Bookmark** and **Heading**.

![Rad Rich Text Box Features Cross Reference 03](https://www.telerik.com/products/wpf/documentation/assets/4801d398f2071d5793516b94393f2bc3/radrichtextbox_features_cross_reference_03.png)

When you have chosen the [type of the reference](https://www.telerik.com/products/wpf/documentation/controls/radrichtextbox/features/references/cross-reference#types-of-cross-references), you should choose one of the items in the “Insert reference to:” combo box. The items depend on the selected item in the “Reference type:” combo box.

The **Insert as hyperlink** checkbox, if checked, will create the field as a hyperlink to the appropriate part of the document. You can click on it while pressing Ctrl. This will force the cursor to move to the start of the part being referenced.

The **For which element** listbox shows all the items of the appropriate type that can be chosen.

Clicking on the **Insert** button inserts the **Cross-Reference** to the document.

## Types of Cross-References

### Figure

These are the options you have when you select the **Figure** reference type:

![Rad Rich Text Box Features Cross Reference 03](https://www.telerik.com/products/wpf/documentation/assets/4801d398f2071d5793516b94393f2bc3/radrichtextbox_features_cross_reference_03.png)

* **Entire Caption** – inserts a field with text equal to the entire caption. In this case the text would be “Figure 1 CaptionText”.

* **Only label and number** - inserts only the label and the number after it. In this case: “Figure 1”.

* **Only caption text** - – inserts the caption text only: “CaptionText” (the text after the label and the number).

* **Page number** - inserts the number of the page on which the field is located. For example if the field is on the third page, the text would be “3”.

* **Above/Below** – inserts the position of the field relative to the part being referenced. For example if we have a **Caption** on the first line of the page and we decide to insert a **Cross-Reference** in the middle of the same page to that **Caption**. We will get the following text – “Above”.

### Table

**Table** and **Figure** are both **Captions** so they have the same options.

![Rad Rich Text Box Features Cross Reference 05](https://www.telerik.com/products/wpf/documentation/assets/20989ba020d58a51a11d8f15ff11aa4a/radrichtextbox_features_cross_reference_05.png)

### Heading

These are the options when **Heading** is selected:

![Rad Rich Text Box Features Cross Reference 06](https://www.telerik.com/products/wpf/documentation/assets/efc3e70fbd450ddb61b8df3e46f2f2be/radrichtextbox_features_cross_reference_06.png)

* **Heading text** - inserts a field with text equal to the one in the heading chosen. For example here we have a paragraph with text “Heading1” (and style Heading1). The text inserted by the field would be “Heading1”.

* **Page Number** - inserts the number of the page on which the field is located. For example if the field is on the fifth page, the text would be “5”.

* **Above/Below** - inserts the position of the field relative to the part being referenced. For example if we have a **Caption** in the middle of the page and we decide to insert a Cross-Reference on the first line of the same page to that Caption. We will get the following text – “Below”.

### Bookmark

When **Bookmark** item is selected in the list with all available bookmarks you see only the names (not the text as with captions and headings)

![Rad Rich Text Box Features Cross Reference 07](https://www.telerik.com/products/wpf/documentation/assets/94a8790f3d345356fc6741a3ec674141/radrichtextbox_features_cross_reference_07.png)

* **Bookmark text** - inserts the text in the bookmark. Here the name is shown, not the text. So the field would look something like “Bookmark Text Here”, given that this is the text of the bookmark with name “bookMark”.

* **Page number** – inserts the number of the page on which the field is located. For example if the field is on the seventh page, the text would be “7”.

* **Above/Below** – inserts the position of the field relative to the part being referenced. For example if we have a **Caption** on the first line of the page and we decide to insert a Cross-Reference in the middle of the page to that **Caption** we will get the text “Above”.

## Inserting a Cross-Reference using RadRichTextBox’s API

All types of **Cross-References** can be inserted using methods of **RadRichTextBox**.

### Inserting Cross-Reference to a Bookmark

Every bookmark has a unique name. So in order to insert a reference to a bookmark, you need its name. **RadRichTextBox** has the following method:

```C#
public void InsertCrossReferenceToBookmark(string bookmarkName, ReferenceContentType contentType, bool insertAsHyperlink)
```

**ReferenceContentType** is an enumeration that has five values – **EntireContent**, **OnlyLabelAndNumber**, **OnlyCaption**, **PageNumber** and **RelativePosition**. As you can see, those values are the same as in the “Insert reference to:” combo box. The parameter “insertAsHyperlink” is pretty self-explanatory and also can be read about [in this article](https://www.telerik.com/products/wpf/documentation/controls/radrichtextbox/features/references/cross-reference#insert-cross-reference).

### Inserting Cross-Reference to a Heading

You have to pass the paragraph (with heading style applied, of course) that you want to create a Reference to. The method signature is as follows:

```C#
    public void InsertCrossReferenceToHeading(Paragraph headingParagraph, ReferenceContentType contentType, bool insertAsHyperlink)
```

The parameters are almost the same, except the first one. It represents the paragraph you want to reference. The other two have the same purpose.Inserting Cross-Reference to a Caption

The method signature is:

```C#
    public void InsertCrossReferenceToCaption(Paragraph captionParagraph, ReferenceContentType contentType, bool insertAsHyperlink)
```

The first parameter represents the paragraph (**Caption**) you want to refer.
