Dim tsc As New TextSearchCriteria("text-to-find", False, False, False)
Dim tl As TextLocation = _
Me.xamSyntaxEditor1.Caret.TextLocation
Dim offset As Integer = _
Me.xamSyntaxEditor1.Document.CurrentSnapshot.OffsetFromLocation(tl)
‘ create a test span, which begins at the current
‘ caret location and extends 200 characters beyond
Dim ts As New TextSpan(offset, 200)
‘ find and replace one occurrence
‘ new text to replace with
‘ search criteria
‘ the text span where to search
‘ start offset
‘ wrap if not found
Me.xamSyntaxEditor1.Document.FindReplace("text-for-replace", tsc, ts, offset, False)