# Get RadDocument Elements Between Annotation Range in RadRichTextBox

## Environment

<table>
<tbody>
<tr>
<th scope="row">Product</th>
<td>UI for WPF RichTextBox</td>
</tr>
<tr>
<th scope="row">Version</th>
<td>2025.1.211</td>
</tr>
</tbody>
</table>

## Description

How to get the RadDocument elements between AnnotationRangeStart and AnnotationRangeEnd.

## Solution

To get the elements in the annotation range, you can use the `NextSibling` of the `AnnotationRangeStart` object, until you get to the `AnnotationRangeEnd`.

```C#
 private static IList<T> GetElementsInAnnotationRange<T>(AnnotationRangeStart start, AnnotationRangeEnd end) where T : DocumentElement
 {
     var result = new List<T>();
     var currentElement = start.NextSibling;
     while (currentElement != null && !(currentElement is AnnotationRangeEnd))
     {
         if (currentElement.GetType() == typeof(T))
         {
             result.Add((T)currentElement);
         }
         currentElement = currentElement.NextSibling;
     }
     return result;
 }
```

```C#
 var spansInHyperlink = GetElementsInAnnotationRange<Span>(hyperlinkAnnotationStart, hyperlinkAnnotationStart.End);
```
