Bad UI performance when using RichTextBox inside a RadGridView

10 posts, 0 answers
  1. papadi
    papadi avatar
    35 posts
    Member since:
    Nov 2008

    Posted 17 Sep 2012 Link to this post

    Hi!
    I have a RadGridView with 5 columns, 2 of which contain rich text. I'm using the following to embed RichTextBox inside my RadGridView.

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Procedure}">
        <telerik:GridViewDataColumn.CellTemplate>
            <DataTemplate>
                    <StackPanel>
                        <telerik:HtmlDataProvider RichTextBox="{Binding ElementName=richTextBox}" Html="{Binding Procedure, Mode=TwoWay}"  />
                        <telerik:RadRichTextBox x:Name="richTextBox" IsReadOnly="True"  />
                    </StackPanel>
            </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>
    </telerik:GridViewDataColumn>

    My problem is that the grid is rendered very slowly. In my sample application, I only have 5 lines, so in total 10 rich text boxes and only half of them have actually data, which are very simple HTML and not more than 10 words each (no tables, just some bold words and some coloring).

    If I try the same without the rich text boxes then the grid is rendered instantly. The same if I use the WebBrowser control to display my data.

    What can I do?
  2. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    103 posts

    Posted 20 Sep 2012 Link to this post

    Hello,

    The problem is caused by the enabled RadGridView virtualization. When a cell goes out of view the instance in it is destroyed and when a cell goes into view the instance is created again. Every time the instance in the cell is created, the binding happens again and it triggers parsing and visualizing the HTML.

    You can turn off the virtualization of the RadGridView by setting EnableRowVirtualization and EnableColumnVirtualization properties to false, but then the performance of RadGridView may be hindered.

    Overall RadRichTextBox is a rather heavy control and is not well-suited to be used in the template of a DataGrid or RadGridView. We will look into the performance issues, but it is not certain if a fix could be implemented.

    Kind regards,
    Nikolay Demirev
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. UI for WPF is Visual Studio 2017 Ready
  4. papadi
    papadi avatar
    35 posts
    Member since:
    Nov 2008

    Posted 20 Sep 2012 Link to this post

    Setting False to these two properties didn't affect at all the behavior. I get exactly the same delay.
  5. Boby
    Admin
    Boby avatar
    595 posts

    Posted 26 Sep 2012 Link to this post

    Hi Papadi,
    RadRichTextBox control is quite heavy and not well-suited for such scenario.
    One additional option you can try is to change the MEF's default composition container to one containing limited set of types, as described in this article - the bare minimum is to set empty type catalog:
    RadCompositionInitializer.Catalog = new TypeCatalog();
    You can also try to disable the spell checking functionality:
    <telerik:RadRichTextBox x:Name="richTextBox" IsReadOnly="True" IsSpellCheckingEnabled="False"  />
    Despite these there isn't much you can do to improve the performance in this specific scenario.


    Regards,
    Boby
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  6. papadi
    papadi avatar
    35 posts
    Member since:
    Nov 2008

    Posted 26 Sep 2012 Link to this post

    Thanks but this didn't help either. No visible effect on the performance.
  7. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 01 Oct 2012 Link to this post

    Hi papadi,

    Our tests show that it takes a little less than 4 s to show a GridView with two RadRichTextBox columns with 12 lines for the first time. Each of the next times that the GridView is shown takes about 1.5 s. These values are registered when the project is run in Release mode, without attached debugger.

    As previously mentioned, the delay the first time the grid view is shown is caused by the fact that RadRichTextBox uses MEF to load the assemblies it needs. Removing the unnecessary assemblies - format providers not used, RichTextBoxUI and its dependencies, and setting the Catalog to an empty type catalog reduces the initial time to less than 3 seconds. Please, find attached a demo illustrating that.

    As Boby mentioned, this is all that can be done to improve the performance. If you have other questions, do not hesitate to get back to us.

    Regards,
    Iva Toteva
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  8. papadi
    papadi avatar
    35 posts
    Member since:
    Nov 2008

    Posted 21 Mar 2013 Link to this post

    We are considering using an alternative html editor instead of telerik's one because of this problem.
    However, before proceeding with that, I would like to ask you if you have done any developments in this problem. Perhaps in a new release (for .NET 4) the editor's performance has significantly improved? Previously you told me that your rich text component was not made for such use. Is this statement still valid with the latest releases?
  9. Boby
    Admin
    Boby avatar
    595 posts

    Posted 25 Mar 2013 Link to this post

    Hi papadi,

    We have done some performance improvements but they are not specifically targeting your use case. You can test the performance at your side using the sample application provided by Iva (it should be runnable against the latest version without any issues) - and decide if it fits your needs.


    All the best,
    Boby
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. Dafna
    Dafna avatar
    2 posts
    Member since:
    Oct 2013

    Posted 21 Oct 2013 Link to this post

    I wrote a  WPF application.
    What can I do if i have a performane problem while displaying HTML in a RichTextBox ( I implemented the binding as in the example in the toolkit )
    I put the Richtextbox in a Dockpanel ( simpler than a Grid).
    The binding data is stored as a string. In case it is simple HTML, the control displays it well but
    my HTML contains a file path to a picture but the file does not exist, when running from visual studio debugger I can see the HTML without picture, Immediately  but when not using the VS application, it takes long long time.
     I set the properties of ReadOnly ( = true) & EnableSpellChecking(= false) and i still have a performance problem.
  11. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 23 Oct 2013 Link to this post

    Hello Dafna,

     As I said in you other forum post about your issue, it will be of great help if you can open a new support ticket and attach the problematic document so we can examine it.

    Regards,
    Mihail
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready