2008-07-18

Retrieve the plain text from the RTF control in WPF

The rich text control in WPF is way more versatile than the Win32 one.
Versatility often means more complex and more complex means that the simpler things are sometimes lost. Like for instance retrieving the plain text from a RTF control.

It is not hard to do but I didn't find any good example through google so here is an example of how to retrieve the plain text from a WPF rich text control:
    TextRange textrange = new TextRange(
        rtfControl.Document.ContentStart, rtfControl.Document.ContentEnd);
    string plainText = textrange.Text;


HTH

1 comment:

Anonymous said...

Thanks!

-Jared