TextAnchor Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Représente une sélection de contenu auquel une annotation est ancrée.
public ref class TextAnchor sealed
public sealed class TextAnchor
type TextAnchor = class
Public NotInheritable Class TextAnchor
- Héritage
-
TextAnchor
Exemples
Considérez une application de lecteur de document simple qui a un volet commentaires. Le volet commentaires peut être une zone de liste qui affiche le texte d’une liste d’annotations ancrées dans 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 suivant montre comment implémenter le gestionnaire d’événements d’une telle zone de liste qui sert de volet commentaires.
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
Remarques
TextAnchor est le type d’objet retourné ResolvedAnchor si vous utilisez des notes collantes et met en surbrillance dans le flux ou les documents fixes.
Propriétés
| Nom | Description |
|---|---|
| BoundingEnd |
Obtient la position de fin de l’ancre de texte. |
| BoundingStart |
Obtient la position de début de l’ancre de texte. |
Méthodes
| Nom | Description |
|---|---|
| Equals(Object) |
Retourne une valeur qui indique si l’ancre de texte est égale à l’objet spécifié. |
| GetHashCode() |
Retourne le code de hachage de l’instance d’ancre de texte. |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |