binding to HTML content

4 posts, 1 answers
  1. kfir ANKORI
    kfir ANKORI avatar
    6 posts
    Member since:
    Apr 2010

    Posted 20 Feb 2011 Link to this post

    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
  2. Answer
    Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 22 Feb 2011 Link to this post

    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!
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dafna
    Dafna avatar
    2 posts
    Member since:
    Oct 2013

    Posted 21 Oct 2013 Link to this post

    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
  5. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 23 Oct 2013 Link to this post

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