TextSearchCriteria tsc = new TextSearchCriteria(
"text-to-find", // text to search for
false, // whole word only
false, // is case sensitive
false // search backwards
);
// obtain current caret location and get the offset from it
TextLocation tl = this.xamSyntaxEditor1.Caret.TextLocation;
int offset = this.xamSyntaxEditor1.Document.CurrentSnapshot.OffsetFromLocation(tl);
// create a test span, which begins at the current
// caret location and extends 200 characters beyond
TextSpan ts = new TextSpan(offset, 200);
// find and replace one occurence
this.xamSyntaxEditor1.Document.FindReplace(
"text-for-replace", // new text to replace with
tsc, // search criteria
ts, // the text span where to search
offset, // start offset
false // wrap if not found
);