Best regards,
/Henrik
11 Answers, 1 is accepted
As you have guessed in order for your application to have good performance you have to keep the instances of RadRichTextBox and in fact any other visual elements to a minimum. Thus showing 200+ RichTextBoxes is not a great option. One possible approach would be to use some kind of virtualizing control such as ListBox, DataGrid or a custom one and prepare a data template with a RichTextBox for each item of this control. This way only the visible control instances would be loaded. Let us know if you meet any obstacles on the way.
Greetings,
Mike
the Telerik team
I have done a little feasibility study now and sadly come to the conclusion that RadRichTextBox is not going to work for me. It is far too heavy and memory intensive to be used in a multiple-instance scenario like this. What I did was put the Microsoft RichTextBox control in the item template of an items control and compared the performance against RadRichTextBox when used in the same fasion. When displaying a short document (3-4 paragraphs of text), I could easily generate a couple of hundred instances of MS RichTextBoxes and still get decently smooth scrolling and a reasonable memory footprint (awful compared to html displayed in a web browser, but still acceptable). With RadRichTextBox I could generate no more than 20 items until the page became almost unusable. When generating 40 items it took about 6-7 seconds for them to even appear. Any more than that and the page crashed and burned in some sort of layout cycle exception. And I have not even mentioned memory consumption. I am attaching my test project for your convenience. Please take a look and see for yourselves.
While RadRichTextBox seems to be a very powerful component when used in a single instance for reading and writing large documents, I feel that you have completely missed the scenario where a rich text component is used to display small "islands" of rich text scattered throughout a page. Surely I cannot be the only person needing a rich text component for a scenario such as this? I know I have seen forum threads asking about using RadRichTextBox in a cell within RadGridView. That is a pretty similar scenario to mine.
I want to ask you to consider implementing something like a RadRichTextBlock, stripped of all editing functionality, context menus, spell checking etc. and only used to render and display rich text produced using RadRichTextBox. The only interactivity needed (at least that I can think of) would be text selection.
Alternatively, is there a way of pulling Xaml from RadRichTextBox that can be rendered using a plain MS RichTextBox? Or maybe "normal" xaml that could just be displayed in a ContentControl? If I could do that I would have a workaround at least.
Sample project:
http://cid-cc43a90a79374ebd.office.live.com/self.aspx/Public/RichTextBoxTest01.zip
Best regards,
/Henrik
Thank you for taking the time to examine the issue in such detail and for the sample project.
We have indeed not considered the possible use of RadRichTextBox in a forum. We have however tested the performance when having many RadRichTextBoxes on one page and are quite satisfied with the results. A prerequisite for that has always been a panel that supports UI virtualization. We strongly advise you against giving up UI virtualization irregardless of your choice for a container of the messages. There are various approaches to implementing your own virtualizing panel on the web, if the standard ones do not offer the user experience you are looking for.
Another option you might want to consider is editing the messages in a RadRichTextBox and showing them in MS RichTextBoxes. We have a simple provider that can convert a RadDocument to and from the XAML that MS RichTextBox uses. We can send its source code to you in the support ticket you opened, so that you can test it and develop it further if needed. It, however, strips some formatting from the RadDocument as RichTextBox supports less formatting options than RadRichTextBox does. Also, note that this format provider will be shipped with the next major release along with the other officially supported ones.
Let us know if that answers your question and the way you wish to proceed.
Iva
the Telerik team
Anyway, thanks for the suggestion about the new provider. Please send me the code in the support ticket and I will try it out. It definitely sounds like it could work. It would be great if you could also elaborate a little on what formatting properties will be lost when using that provider.
I would also appreciate some feedback on my idea for a light weight read-only rich text viewer (RichTextBlock if you will). To me that sounds like quite a useful addition to your component suite. I mean, we are not just talking about forums. Any application with smaller text areas like help texts, advanced tooltips, user comments, sticky notes etc. would benefit from the use of rich text rather than just plain text. And using the full RadRichTextBox in read-only mode for these purposes just seems so overkill. Sure, it will work fine on my quad-core dev machine, but I am pretty sure that my 3 year old netbook will be less happy if I render 5-7 instances of RadRichTextBox on the same page and load it up. Just give the idea some thought, that is all I ask.
Best regards,
/Henrik
The paging algorithm consists of creating only a set of RadRichTextBox, for our case it was 25. For the next page you use the same created controls and re-initialize them. that way your application can scale well.
I think u will have an issue with typing speed inside the RadRichTextBox when you have a large text inside.
It is important to choose the right technology in advance for your project.
I have been building a multi-threaded comment system using asp.net and jquery for about a month now. I droped Silverlight because of the performance issues.
@Telerik: See, I am not the only one with performance issues here.
Best regards,
/Henrik
Thank you for the follow-up and the constructive suggestions.
@Rabeeh Thank you for sharing your experience and taking active part in this discussion.
To the topics raised:
- As for your suggestion of a RadRichTextBlock, RadRichTextBox in read-only mode is in fact stripped of all additional overhead that comes from the editing options and there is little that can be done at this point to optimize the performance.
We have some ideas for improvements but still adding a lot of RichTextBox controls with lots of text to the Silverlight app element tree will have relatively poor performance. So, unless you decide to use virtualization or a limitted number of posts/ rich text boxes a page, unfortunately, RadRichTextBox may not be the right choice for you.
Another Idea for optimization at your side is to substitute the read-only RichTextBox-es with images (using WriteableBitmap) or HtmlPalaceHolders.The solution with HtmlPlaceHolder though is limited to Web-Browser apps only and the HtmlPlaceHolder content is not actually native for Silverlight and animations and some other Silverlight UI goodies will not work. - The solution with RichTextBoxes for the read-only posts turns out to be an option of limited capabilities, as RichTextBoxes do not support inline images and lists;
- When it comes to the poorer performance with larger documents, that is quite natural. However, when virtualization is utilized, the performance is bearable even for documents of more than 100 pages.
Kind regards,
Iva
the Telerik team
It would be really nice if telerik created a very very simple RTB control without all the bells and whistles... kind of like the one im typing in that only has bold,italic, indenting and a couple of other options.
Just wanted to thumbs a need for a leaner RTB...
Back to the MS control for now.