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

binding to HTML content

3 Answers 231 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
kfir ANKORI
Top achievements
Rank 1
kfir ANKORI asked on 20 Feb 2011, 09:24 AM
Hello,

i am trying to use the RadRichTextBox as an html editor. for starters, i simply tried to bind it to html comming from a different text box.
i keep getting binding error on this simple example.
can you please help? what am i doing wrong?

here is the xaml: (i get binding errors on both binding expressions)
<UserControl x:Class="WpfApplication27.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:telHtml="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents.FormatProviders.Html"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <telHtml:HtmlDataProvider x:Key="htmlDataProvider" 
                    Html="{Binding ElementName=source, Path=Text, Mode=TwoWay}"
                                              RichTextBox="{Binding ElementName=editor}" 
                                     />
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <telerik:RadRichTextBox x:Name="editor"/>
        <TextBox AcceptsReturn="True" Name="source" Grid.Column="1"/>
    </Grid>
</UserControl>

Thanks!

Kfir

3 Answers, 1 is accepted

Sort by
0
Accepted
Andrew
Telerik team
answered on 22 Feb 2011, 02:35 PM
Hello kfir ANKORI,

There is nothing wrong in your code. In fact it works perfectly when run in Silverlight. The problem here is that you've placed the format provider in UserControl's resources. This would be the approach in Silverlight, but here in WPF the format provider has to be present in the visual tree for the binding to work. This is due to a limitation in WPF, where bindings with ElementName don't work when specified within the resources.
So everything you have to do is just move it somewhere in the Grid.
If you meet any other difficulties, feel free to contact us immediately.
 
Regards,

Andrew
the Telerik team

Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Dafna
Top achievements
Rank 1
answered on 21 Oct 2013, 06:54 AM
I have a performance problem while using RichTextBox in HTML formating
The HTML data is stored as a string. I binded the data as in your sample, it works but very slowly
and while drawing data all the aaplication is stuck.
The situation become worse in case the html string contains png/image/picture

Do you have any good idea how to improve the performance
best regards, dafna
0
Mihail
Telerik team
answered on 23 Oct 2013, 08:16 AM
Hello Dafna,

Could you please open new support ticket with attached the problematic document so we can examine it and check where is the bottleneck of the performance issue?

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 >>
Tags
RichTextBox
Asked by
kfir ANKORI
Top achievements
Rank 1
Answers by
Andrew
Telerik team
Dafna
Top achievements
Rank 1
Mihail
Telerik team
Share this question
or