Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF RichTextBox Performance

WPF's RichTextBox control's performance is real slow when a 50KB text document is loaded. Scrolling laggy and pressing Ctrl-A to select all the text takes more than 10 seconds. (This is intantaneous on Notepad).

I'm not doing any fancy bitmap effects. Is this normal? Even typing on an empty RichTextBox seems a bit laggy than normal.

Are there fixes for this? Alternatives? Thanks!

like image 231
moogs Avatar asked Jan 16 '09 05:01

moogs


2 Answers

You might need to consider using a different text box control.

Daniel Grunwald has written the Wpf text editor for SharpDevelop completely from scratch. It is called AvalonEdit and a good article is on codeproject:

http://www.codeproject.com/KB/edit/AvalonEdit.aspx

It seems that he has done optimizations for large files.

like image 126
Patrick Klug Avatar answered Sep 21 '22 13:09

Patrick Klug


I bet Scintilla will outperform most (if not all) free alternatives out there. For WPF, use a WPF wrapper. E.g. ScintillaNET.WPF (haven't tried it though).

Pros

  • Excellent performance.
  • Great number of syntax highlighting schemes.

Cons

  • Don't expect native WPF features to work. E.g. scaling, touch...
like image 38
l33t Avatar answered Sep 19 '22 13:09

l33t