言語

AnnotationHelper.GetAnchorInfo(AnnotationService, Annotation) メソッド

定義

指定した注釈に関するアンカー位置などのアンカー情報を提供する IAnchorInfo オブジェクトを返します。

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

パラメーター

service
AnnotationService

この操作に使用する注釈サービス。

annotation
Annotation

アンカー情報を取得する注釈。

返品

指定した注釈に関するアンカー情報を提供する IAnchorInfo オブジェクト。解決できない場合は null

コメント ウィンドウがある単純なドキュメント リーダー アプリケーションを考えてみましょう。 コメント ウィンドウは、ドキュメントに固定されている注釈のリストのテキストを表示するリスト ボックスである場合があります。 ユーザーがリスト ボックスで項目を選択すると、アプリケーションは、対応する注釈オブジェクトが固定されているドキュメント内の段落を表示します。

次の例では、コメント ウィンドウとして機能するこのようなリスト ボックスのイベント ハンドラーを実装する方法を示します。

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

適用対象

こちらもご覧ください