IAnchorInfo.ResolvedAnchor 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得物件,表示樹狀目錄中已解析 Anchor 的位置。
public:
property System::Object ^ ResolvedAnchor { System::Object ^ get(); };
public object ResolvedAnchor { get; }
member this.ResolvedAnchor : obj
Public ReadOnly Property ResolvedAnchor As Object
屬性值
物件,表示樹狀目錄中已解析 Anchor 的位置。 此型別是由標註物件的型別指定。 非固定格式或固定格式文件中的自黏便箋和醒目提示一定會解析為 TextAnchor 物件。
範例
請考慮具有批註窗格的簡單檔讀取器應用程式。 註解窗格可能是清單方塊,其中顯示來自錨定到文件之註釋清單的文字。 如果使用者在清單方塊中選取項目,則應用程式會將對應註釋物件所錨定之文件中的段落帶入檢視。
下列範例示範如何實作做為批註窗格之這類清單方塊的事件處理常式:
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