-1

I need to make a Button for bolding selected text of a string in TextBox/RichTextBox, but I don't know how to do it with code behind.

TextBox1.SelectedText = new FontStyle("Bold")

It is not working.

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • 4
    Possible duplicate of [Set specific text to bold in WPF RichTextBox](https://stackoverflow.com/questions/33559679/set-specific-text-to-bold-in-wpf-richtextbox) – Pintu Paul Mar 29 '19 at 02:54

1 Answers1

1

Try this code for a rich TextBox:

RichTextBox1.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
Dark Templar
  • 1,130
  • 8
  • 10