RadRichTextBox will not display in a ListBox

7 posts, 0 answers
  1. Josh
    Josh avatar
    5 posts
    Member since:
    Jan 2011

    Posted 10 Jan 2011 Link to this post

    I've run into what appears to be a bad layout bug in the control: if I put the control in a listbox template, it simply doesn't render unless I set the Height and Width explicitly. 

    To be precise, I made a custom UserControl containing a ribbon control and a rich text control (because I use this combination together in many places).  If I place this user control on a page, it works fine.  If I put it in a listbox template and specify the Height and Width, it works fine.  But if I rely on the Silverlight layout, I just see a piece of the ApplicationMenu, and none of the rest of the toolbar or the rich text control.

    This is similar to the bug reported here:

    http://www.telerik.com/community/code-library/silverlight/general/binding-the-content-of-radrichtextbox-in-xaml.aspx#1373387

    Unfortunately, setting the size explicitly isn't really acceptable, because I need to control to flow properly in the application, and I can't find any way to do this with a fixed size.

    Please advise.  Thank you.
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 12 Jan 2011 Link to this post

    Hi Josh,

     The matter is lying in the way ListBox measures its children. When the horizontal scroll bar is enabled, it measures all controls in infinite width (allowing them to take as much space as they need), which causes trouble with RadRichTextBox.

    If you disable the horizontal scroll bar of the ListBox like this:

    <ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled"... />

     it will measure its children in the same width as it is (that is also the case with all other ScrollPanels). That will allow RadRichTextBox to layout the document properly. Also, please note that in this case, the text will wrap inside RadRichTextBox. This should fit your case well.
    Let us know if you experience any further problems.

    Kind regards,
    Iva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. Matthew
    Matthew avatar
    3 posts
    Member since:
    Sep 2010

    Posted 12 Jan 2011 Link to this post

    I've done this, but it's not a very good workaround, because the listbox is outside the user control that contains the richtextbox, and this violates the encapsulation.  In other words, the layout is like this:

    Page
      ListBox
        ListBoxTemplate
           UserControl

    And the UserControl contains the richtextbox, along with a ribbon bar and various other tools that make the richtextbox more useful.  But since the person using the Listbox has no idea about this bug in the richtext control, there's nothing to suggest that the listbox shouldn't be allowed to scroll.
  4. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 17 Jan 2011 Link to this post

    Hi Matthew,

    We will allow setting RadRichTextBox's width to Auto in the future, which will allow the control to measure its size properly in containers that measure their children with infinity (ListBoxes in that number).
    However, a drawback of using Auto width will be the fact that UI VIrtualization, which is otherwise made use of, will be turned off. This will increase the memory footprint of the application. The performance on the whole will also suffer, because lots of UI elements would have to be created and put in the visual tree at the same time.
    If you have any other questions, do not hesitate to contact us again.

    Greetings,
    Iva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  5. legend613
    legend613 avatar
    2 posts
    Member since:
    Jan 2011

    Posted 20 Jan 2011 Link to this post

    why I can't find RichTextBox when develop Windows Phone7 application?????
  6. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 24 Jan 2011 Link to this post

    Hi Xu,

    RadRichTextBox is included in the RadControls for Silverlight suite and not in the Windows Phone Controls. The rich text box is currently built only against Silverlight 4. The Silverlight for Windows Phone is rather different, which prevents the direct use of the control in a Windows Phone application.
    There is a list of the controls included in the Windows Phone suite here.
    If you have other questions, do not hesitate to contact us again.

    All the best,
    Iva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  7. Robert Bergman
    Robert Bergman avatar
    6 posts
    Member since:
    Nov 2009

    Posted 30 Mar 2011 Link to this post

    Hi Iva ,

    Thanks a ton for the solution. I required so many hours to resolve that issue.


    Thanks,
    Prashant.
Back to Top