RadRichTextBox Html binding doesn't work if the control is in a listbox item template

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

    Posted 06 Jan 2011 Link to this post

    I'm following the example for html binding given here:

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

    First, I had the same problem reported by the original poster, which is that the control doesn't show at all if the Height and Width are not set in the XAML; setting them explicitly did fix that problem, but now I'm finding that HTML binding simply doesn't work if the rich text control is in a ListBox, while the exact same code works fine if the control is not in a listbox.  I can't easily rework my application, so I really need to get this working within the listbox.  Please advise ASAP!  Thank you.
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 10 Jan 2011 Link to this post

    Hi Josh,

    The solution to the problem can also be found in the forum thread you have posted. Namely, a separate data provider has to be defined for every RadRichTextBox. There is also a working demo in one of the posts, which you can refer to, if needed.
    In case that does not help in your case, we would appreciate some more information on your implementation.

    Best wishes,
    Iva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. Josh
    Josh avatar
    5 posts
    Member since:
    Jan 2011

    Posted 10 Jan 2011 Link to this post

    Perhaps I wasn't clear about that, but I do have a separate html provider for every one of my rich text controls, and I still have the problem.
  4. Josh
    Josh avatar
    5 posts
    Member since:
    Jan 2011

    Posted 10 Jan 2011 Link to this post

    I think I found the problem, or a workaround anyway.  I was using sample code that put the xaml for the html provider in the page resources:
    <UserControl.Resources>
       <telerikHtml:HtmlDataProvider x:Key="htmlDataProvider" RichTextBox="{Binding ElementName=rtb}" Html="{Binding Path=Html, ElementName=UserControl, Mode=TwoWay}"/>
    </
    UserControl.Resources>
    I moved this to the resources of the rich text control itself:

    <telerik:RadRichTextBox.Resources>
        <telerikHtml:HtmlDataProvider x:Key="htmlDataProvider" RichTextBox="{Binding ElementName=rtb}" Html="{Binding Path=Html, ElementName=UserControl, Mode=TwoWay}"/>
    </telerik:RadRichTextBox.Resources>
    and that seemed to fix it.  To my mind, this is a bug that should be fixed.
  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 12 Jan 2011 Link to this post

    Hi Josh,

    We are glad that you have managed to resolve the issue.
    As described in our help article, in order to utilize data binding in data templates, the data provider has to be defined in the corresponding RadRichTextBox's Resources. We will consider scheduling your scenario for revision, but I would highly recommend sticking to declaring the provider in the resources of the rich text box.
    If you have any other issues, do not hesitate to contact us again.

    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>>
  6. Matthew
    Matthew avatar
    3 posts
    Member since:
    Sep 2010

    Posted 12 Jan 2011 Link to this post

    Actually, if you read the article that you link to, the provider is NOT in the resources of the rich text box, it is in the resources of the UserControl.  Both scenarios should be equivalent, but the scenario in the help article does not seem to work.
  7. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 13 Jan 2011 Link to this post

    Hello Josh,

    You are right, I am sorry. I was referring to the last example on the page, where RadRichTextBox is in a DataTemplate, as this case is most similar to yours. The main problem is that when RadRichTextBox is in a DataTemplate the binding of the DataProvider to the rich text box is not working, if the DataProvider is declared outside the scope of the DataTemplate. This is simply how XAML works. We will update the article and make sure it is clearer as soon as possible.

    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>>
Back to Top