New to Telerik UI for WPFStart a free 30-day trial

Get RadDocument Elements Between Annotation Range in RadRichTextBox

Updated on Mar 31, 2026

Environment

ProductUI for WPF RichTextBox
Version2025.1.211

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);
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support