AnnotationHelper.GetAnchorInfo(AnnotationService, Annotation) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve um IAnchorInfo objeto que fornece informação de ancoragem, como a localização da âncora, sobre a anotação especificada.
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
Parâmetros
- service
- AnnotationService
O serviço de anotação a usar para esta operação.
- annotation
- Annotation
A anotação para obter informação de ancoragem.
Devoluções
Um IAnchorInfo objeto que fornece informação de ancoragem sobre a anotação especificada, ou null se esta não puder ser resolvida.
Exemplos
Considere uma aplicação simples de leitor de documentos que tem um painel de comentários. O painel de comentários pode ser uma caixa de listagem que exibe o texto de uma lista de anotações ancoradas em um documento. Se o usuário selecionar um item na caixa de listagem, o aplicativo exibirá o parágrafo no documento ao qual o objeto de anotação correspondente está ancorado.
O exemplo a seguir demonstra como implementar o manipulador de eventos de tal caixa de listagem que serve como o painel de comentários.
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