TextAnchor 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示批注定位到的内容选择。
public ref class TextAnchor sealed
public sealed class TextAnchor
type TextAnchor = class
Public NotInheritable Class TextAnchor
- 继承
-
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
注解
TextAnchor 是在流或固定文档中使用便笺和突出显示时返回 ResolvedAnchor 的对象类型。
属性
| 名称 | 说明 |
|---|---|
| BoundingEnd |
获取文本定位点的结束位置。 |
| BoundingStart |
获取文本定位点的起始位置。 |
方法
| 名称 | 说明 |
|---|---|
| Equals(Object) |
返回一个值,该值指示文本定位点是否等于指定的对象。 |
| GetHashCode() |
返回文本定位点实例的哈希代码。 |
| GetType() |
获取当前实例的 Type。 (继承自 Object) |
| MemberwiseClone() |
创建当前 Object的浅表副本。 (继承自 Object) |
| ToString() |
返回一个表示当前对象的字符串。 (继承自 Object) |