Live Chat Icon For mobile
Live Chat Icon

How can I Match Annotations with Annotated Objects ?

Platform: WPF| Category: Annotations

You can match annotations with the corresponding annotated objects. For example, consider a simple document reader application that has a comments pane. The comments pane might be a listbox that displays the text from a list of annotations that are anchored to a document. If the user selects an item in the listbox, then the application brings into view the paragraph in the document that the corresponding annotation object is anchored to.

The following piece of C # code demonstrates how to implement the event handler of such a listbox that serves as the comments pane.

[C#]

void annotationsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

    Annotation comment = (sender as ListBox).SelectedItem as Annotation;
    if (comment != null)
    {
        // IAnchorInfo info;
        // service is an AnnotationService object
        // comment is an Annotation object
        info = AnnotationHelper.GetAnchorInfo(this.service, comment);
        TextAnchor resolvedAnchor = info.ResolvedAnchor as TextAnchor;
        TextPointer textPointer = (TextPointer)resolvedAnchor.BoundingStart;
        textPointer.Paragraph.BringIntoView();
    }
} 

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.