This is a migrated thread and some comments may be shown as answers.

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

6 Answers 287 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Josh
Top achievements
Rank 1
Josh asked on 06 Jan 2011, 08:00 PM
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.

6 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 10 Jan 2011, 11:10 AM
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
0
Josh
Top achievements
Rank 1
answered on 10 Jan 2011, 02:26 PM
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.
0
Josh
Top achievements
Rank 1
answered on 10 Jan 2011, 04:54 PM
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.
0
Iva Toteva
Telerik team
answered on 12 Jan 2011, 05:31 PM
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>>
0
Matthew
Top achievements
Rank 1
answered on 12 Jan 2011, 05:50 PM
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.
0
Iva Toteva
Telerik team
answered on 13 Jan 2011, 09:14 AM
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>>
Tags
RichTextBox
Asked by
Josh
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Josh
Top achievements
Rank 1
Matthew
Top achievements
Rank 1
Share this question
or