Binding problem

3 posts, 0 answers
  1. Fredrik
    Fredrik avatar
    58 posts
    Member since:
    Mar 2013

    Posted 06 Jan 2016 Link to this post

    Hello am using RichTextBox and the htmldataprovider for binding directly to a property on a db entity.

    <telerikHtml:HtmlDataProvider Name="htmlDataProvider" RichTextBox="{Binding ElementName=radRichTextBox}" Html="{Binding Entity.HtmlProperty,Mode=TwoWay}" />

    My Entity.HtmlProperty can allready contain html text data to be displayed so i need to be a two way binding.


    My problem:

    RichTextBox is not present in the visual tree initially by the application page. it gets presented in a slide in panel on demand.

    Meaning the data of my existing property is loaded before the RichTextBox  is presented

    Due to slow loading of the RichTextBox or some other reason my existing data content gets replaced by RichTextBox empty html content(even if nothing is typed, there still is a bunch of html code)

    Is there any non dirty way to resolve this probem?

    (one option I can think of is to is to trap the loaded event and add the binding to the HtmlDataProvider in code, but am not sure how to do this?)

  2. Fredrik
    Fredrik avatar
    58 posts
    Member since:
    Mar 2013

    Posted 06 Jan 2016 in reply to Fredrik Link to this post

    Got this working, might be the best solution

    private async Task LoadRichTextBox(object par)
                    var rtb = par as RadRichTextBox;

                    Binding b = new Binding("Entity.Html");
                    b.Source = EntityCarrier;
                    b.Mode = BindingMode.TwoWay;

                    HtmlDataProvider hdp = new HtmlDataProvider();
                    hdp.RichTextBox = rtb;
                    hdp.SetBinding(HtmlDataProvider.HtmlProperty, b);


  3. Todor
    Todor avatar
    168 posts

    Posted 07 Jan 2016 Link to this post

    Hi Fredrik,

    Since the RadRichTextBox is added later to the visual tree, the solution you found to make the things working properly is a correct one. 

    If you have further questions, please do not hesitate to contact us again.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top