AnnotationHelper.GetAnchorInfo(AnnotationService, Annotation) Méthode

Définition

Retourne un objet IAnchorInfo qui fournit des informations d'ancrage, telles que l'emplacement d'ancrage, pour l'annotation spécifiée.

C#
public static System.Windows.Annotations.IAnchorInfo GetAnchorInfo (System.Windows.Annotations.AnnotationService service, System.Windows.Annotations.Annotation annotation);

Paramètres

service
AnnotationService

Service d'annotations à utiliser pour cette opération.

annotation
Annotation

Annotation pour laquelle obtenir des informations d'ancrage.

Retours

IAnchorInfo

Objet IAnchorInfo qui fournit des informations d'ancrage pour l'annotation spécifiée ou null en cas de non-résolution.

Exemples

Considérez une application de lecteur de documents simple qui a un volet commentaires. Le volet de commentaires peut être une zone de liste qui affiche le texte à partir d’une liste d’annotations ancrées à un document. Si l’utilisateur sélectionne un élément dans la zone de liste, l’application affiche le paragraphe du document auquel l’objet d’annotation correspondant est ancré.

L’exemple ci-dessous montre comment implémenter le gestionnaire d’événements de ce type de zone de liste pour servir de volet de commentaires.

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();
    }
}

S’applique à

Produit Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

Voir aussi