This is a migrated thread and some comments may be shown as answers.

How to get annotation of selection?

2 Answers 84 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 03 May 2012, 04:28 PM
Hi,

How do you get the custom annotation of a selected span?

For example:
<t:Paragraph>
  <custom1:SemanticRangeStart AnnotationID="1" Name="SemanticRange 0" />
     <t:Span FontFamily="Segoe UI" FontSize="14" FontStyle="Normal" FontWeight="Normal" Text="Appliances: " />
  <custom1:SemanticRangeEnd AnnotationID="1" />
  <custom1:SemanticRangeStart AnnotationID="2" Name="SemanticRange 1" />
     <t:Span FontFamily="Segoe UI" FontSize="14" FontStyle="Normal" FontWeight="Normal" Text="Dishwasher" />
  <custom1:SemanticRangeEnd AnnotationID="2" />
</t:Paragraph>

Suppose my select range covers the last span which contains the text "Dishwasher".
From the selection, how can I retrieve it's annotation programmatically?

Thank you for your time,

Rob

2 Answers, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 04 May 2012, 05:08 PM
Hello Robert,
We are planning to expose such API of RadDocument, but until then, you can use the extension methods from the attached file. Another methods that may be useful for you are the various RadDocument.GetContainingAnnotationRanges overloads.

All the best,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Robert
Top achievements
Rank 1
answered on 04 May 2012, 05:41 PM
Cool, thank you very much Boby, it works perfectly!

For any other newbies out there like myself, you just have to include the RadDocumentExtensions class file into your project and then call the methods like so:

This is to get the SelectedAnnotations:
List<SemanticRangeStart> selectedAnnotation = RadDocumentExtensions.GetSelectedAnnotationRangeStarts<SemanticRangeStart>(this.radRichTextBox.Document);


Thanks again Boby. I look forward to this being included in the API.
Tags
RichTextBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Boby
Telerik team
Robert
Top achievements
Rank 1
Share this question
or