Me.xamSyntaxEditor1.Document.Language.SyntaxTreeCreated += Language_SyntaxTreeCreated
Private Sub Language_SyntaxTreeCreated(sender As Object, e As SyntaxTreeCreatedEventArgs)
Dim syntaxNode = e.SyntaxTree.RootNode.GetChild(0)
' Add a diagnostic
Dim newTree = e.SyntaxTree.AddDiagnostic(syntaxNode, New Diagnostic(New TextSpan(syntaxNode.LeadingIgnoredContentLength, syntaxNode.GetText().Trim().Length), "Something wrong happened!", DiagnosticSeverity.Warning))
' Add an annotation
Dim anotherNewTree = newTree.AddAnnotation(newTree.RootNode.GetChild(0), New SyntaxAnnotation())
e.SyntaxTree = anotherNewTree
End Sub