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

Rich text box not displaying HTML text (HtmlDataProvider)

5 Answers 632 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Shiv
Top achievements
Rank 1
Shiv asked on 03 Jul 2013, 09:35 PM
Hi,

I recently updated the telerik version from 2012.2.912 to 2013.1.403. 
Previously I implemented  a richtextbox which displays html text using HtmlDataProvider. With the upgrade to new version Im not able to display the html text in the richtextbox anymore. Did anyone come across something similar like this? There has been no code change. Is there something more we need to in the new version?
here is the snippet of my code :
 <telerik:RadRichTextBox
                            x:Name="BodyViewText"
                            IsSpellCheckingEnabled="False"
                            AcceptsReturn="True"
                            VerticalScrollBarVisibility="Auto"
                            IsReadOnly="True">
                            <telerik:RadRichTextBox.Resources>
                                <html:HtmlDataProvider
                                    x:Name="HtmlDataProvider"
                                    Html="{Binding Path=DisplayHTML, Mode=TwoWay}"
                                    RichTextBox="{Binding ElementName=BodyViewText}" />
                            </telerik:RadRichTextBox.Resources>
                        </telerik:RadRichTextBox>


Please help me in this regard.

Thank you in advance.

5 Answers, 1 is accepted

Sort by
0
CHRISTIAN
Top achievements
Rank 1
answered on 10 Jul 2013, 08:56 AM
I have the same problem now. Any solution?

Edit:

I´m not using the RibbonView. This is my XAML:

<telerik:HtmlDataProvider Html="{Binding ElementName=textbox, Path=Text, Mode=TwoWay}"  RichTextBox="{Binding ElementName=richTextBox}" />
<telerik:RadRichTextBox x:Name="richTextBox"/>
<TextBox x:Name="textbox"/>


If there is some text in the richtextbox and i type something in the normal textbox the text disappears, but thats all.

If i type something in the richtextbox nothing happens.
0
Shiv
Top achievements
Rank 1
answered on 10 Jul 2013, 03:37 PM
I fixed it ! We need to add export settings for the Htmldataprovider

Here is the snippet.
 <telerik:RadRichTextBox 
                            x:Name="RichText" 
                           Margin="5"
                            HorizontalAlignment="Stretch"
                            IsSpellCheckingEnabled="False"
                            AcceptsReturn="True"
                           IsReadOnly="True"/>
                        <telerik:HtmlDataProvider Html="{Binding EmailTemplate.MacroBody}" RichTextBox="{Binding ElementName=RichText
}">
                            <telerik:HtmlDataProvider.FormatProvider>
                                <telerik:HtmlFormatProvider>
                                    <telerik:HtmlFormatProvider.ExportSettings>
                                        <telerik:HtmlExportSettings DocumentExportLevel="Document" StylesExportMode="Inline"/>
                                    </telerik:HtmlFormatProvider.ExportSettings>
                                </telerik:HtmlFormatProvider>
                            </telerik:HtmlDataProvider.FormatProvider>
                        </telerik:HtmlDataProvider>
0
CHRISTIAN
Top achievements
Rank 1
answered on 11 Jul 2013, 07:09 AM
Yayyyy it works thanks!
0
Iva Toteva
Telerik team
answered on 11 Jul 2013, 07:26 AM
Hello,

RadRichTextBox loads the format providers using MEF. One of the changes that was recently done regarding the data providers is that they now use the format provider that is cached by MEF and do not create another instance. That is why if your application uses library caching for example, MEF will not be able to load the format provider and the data providers will not work. 

In a nutshell, you can add the HtmlFormatProvider in XAML as you have done (it is not required to create export settings, if no customizations will be applied). Another option would be to register the format provider like this:

DocumentFormatProvidersManager.RegisterFormatProvider(new HtmlFormatProvider());

or you could also adopt the approach explained in this article. The solution proposed in the documentation will also address issues related to dialogs and pop-ups not being loaded and not being available to use.

I hope this helps!

Regards,
Iva Toteva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
0
Tony
Top achievements
Rank 1
answered on 28 Aug 2014, 09:34 PM
Iva,

I have recently run into this problem with 2013.2.827.45 Telerik libraries (and  2014.2.617.45 libraries) with a WPF solution that embeds the Telerik libraries inside my application.  I have the HtmlFormatProvider in XAML as you state but that does not work.  I had to use one of your other options.  I used the following code in the constructor of the view that contains the RadRichTextBox:

public Foo()
{
    RadCompositionInitializer.Catalog =
new TypeCatalog(typeof (HtmlFormatProvider));
    InitializeComponent();
}

Doing this got the RadRichTextBox to show my Html content. 

Note:  The RadRichTextBox and Html content would also work as advertised when I would not embed the Telerik libraries. 

Hope this helps others in the same boat.
Tags
RichTextBox
Asked by
Shiv
Top achievements
Rank 1
Answers by
CHRISTIAN
Top achievements
Rank 1
Shiv
Top achievements
Rank 1
Iva Toteva
Telerik team
Tony
Top achievements
Rank 1
Share this question
or