AnnotationHelper.GetAnchorInfo(AnnotationService, Annotation) Methode

Definitie

Retourneert een IAnchorInfo object dat ankerinformatie biedt, zoals de ankerlocatie, over de opgegeven aantekening.

public:
 static System::Windows::Annotations::IAnchorInfo ^ GetAnchorInfo(System::Windows::Annotations::AnnotationService ^ service, System::Windows::Annotations::Annotation ^ annotation);
public static System.Windows.Annotations.IAnchorInfo GetAnchorInfo(System.Windows.Annotations.AnnotationService service, System.Windows.Annotations.Annotation annotation);
static member GetAnchorInfo : System.Windows.Annotations.AnnotationService * System.Windows.Annotations.Annotation -> System.Windows.Annotations.IAnchorInfo
Public Shared Function GetAnchorInfo (service As AnnotationService, annotation As Annotation) As IAnchorInfo

Parameters

service
AnnotationService

De aantekeningsservice die voor deze bewerking moet worden gebruikt.

annotation
Annotation

De aantekening voor het ophalen van ankerinformatie voor.

Retouren

Een IAnchorInfo object dat ankerinformatie biedt over de opgegeven aantekening of null als het niet kan worden opgelost.

Voorbeelden

Overweeg een eenvoudige toepassing voor documentlezers met een opmerkingenvenster. Het opmerkingenvenster kan een keuzelijst zijn waarin de tekst wordt weergegeven uit een lijst met aantekeningen die zijn verankerd aan een document. Als de gebruiker een item in de keuzelijst selecteert, wordt in de toepassing de alinea in het document weergegeven waarnaar het bijbehorende aantekeningsobject is verankerd.

In het volgende voorbeeld ziet u hoe u de gebeurtenis-handler van een dergelijke keuzelijst implementeert die fungeert als het opmerkingenvenster.

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();
    }
}
Private Sub annotationsListBox_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)

    Dim comment As Annotation = TryCast((TryCast(sender, ListBox)).SelectedItem, Annotation)
    If comment IsNot Nothing Then
        ' service is an AnnotationService object
        ' comment is an Annotation object
        info = AnnotationHelper.GetAnchorInfo(Me.service, comment)
        Dim resolvedAnchor As TextAnchor = TryCast(info.ResolvedAnchor, TextAnchor)
        Dim textPointer As TextPointer = CType(resolvedAnchor.BoundingStart, TextPointer)
        textPointer.Paragraph.BringIntoView()
    End If
End Sub

Van toepassing op

Zie ook