It is necessary to highlight the given substring in the RichEditBox document. To do this, I wrote a method:
private async Task ChangeTextColor(string text, Color color) { string textStr; bool theEnd = false; int startTextPos = 0; myRichEdit.Document.GetText(TextGetOptions.None, out textStr); while (theEnd == false) { myRichEdit.Document.GetRange(startTextPos, textStr.Length).GetText(TextGetOptions.None, out textStr); var isFinded = myRichEdit.Document.GetRange(startTextPos, textStr.Length).FindText(text, textStr.Length, FindOptions.None); if (isFinded != 0) { string textStr2; textStr2 = myRichEdit.Document.Selection.Text; var dialog = new MessageDialog(textStr2); await dialog.ShowAsync(); myRichEdit.Document.Selection.CharacterFormat.BackgroundColor = color; startTextPos = myRichEdit.Document.Selection.EndPosition; myRichEdit.Document.ApplyDisplayUpdates(); } else { theEnd = true; } } } In the debugger, you can see that the substring is located and isFinded is equal to the number of characters in the found substring. That is, the fragment was found and, judging by the description of the FindText method, it should be selected, but not. In textStr2, an empty string is returned and, accordingly, the color does not change. I can not figure out what the error is.