views:

630

answers:

1

How to replace a character in WPf richtextbox?

A: 

Hi,
WPF RichTextBox does not have any direct property or method that will convert its content to string which can in turn be used for manipulation. You could try something like this

TextRange textRange = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);

string rtbContent = textRange.Text;

Now that you have the contents in a string, you can easily replace the part of the string you want.

HTH

Anand