I am expanding the functionality of WPF Richtextbox. I want a certain text to become bold when I enter it. I was able to get the selected text in bold, but the text following the bold word will also become bold ...
Here is an example of my code:
private bool _Running = false;
void CustomRichTextBox_TextChange(object sender, TextChangedEventArgs e)
{
if(_Running)
return;
_Running = true;
var boldMe = new TextRange(textPointer1, textPointer2);
boldMe.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
_Running = false;
}
I want:
NOTBOLDED NOTBOLDED BOLDED NOTBOLDED
but I get:
NOTBOLDED NOTBOLDED BOLDED NOTBOLDED
** Please note that it is printed in bold when printing.
How to prevent text selection after the shifted word?
This is not a repeating question, because the decision made for the provided link is intended for WinForms, and the rest is for predefined text.