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

RadRichTextBox in a TransitionControl

2 Answers 38 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Gunnar
Top achievements
Rank 1
Gunnar asked on 21 Apr 2011, 11:08 PM
RadRichTextBox seems to have some kind of binding problem if the UserControl holding the RadRichTextBox isn't visible on screen when the Bind is supposed to happen.

It is somewhat complex to describe, but what I try to accomplish is some background loading of data. I have a TransitionControl whose Content is bound to the Tag of the SelectedItem of a RadTreeview. Rather basic stuff that works OK when configured as "default".

The loaded UserControls all have their own DomainDataSource. If I configure the DomainDataSource for AutoLoad, everything works as expected, all Bindings are working and all data is visible when the UserControl is activated in the TransitionControl. The problem is that the DomainDataSource Load isn't triggered until I actually load the UserControl in the TransitionControl; a fact that has a number of unwanted effects for me.

So, I have written a Load() public method in the UserControls that triggers the DomainDataSource load, and I call this method as soon as I have instantiated the UserControl(s). The effect is that the DomainDataSource load is performed in the background and the data is already present when the user selects the entry in the TreeView and the UserControl gets loaded into the TransitionControl the first time.

And now to get back to the problem at hand; When performing this background load, all Binding works except for RadRichTextBox. When the user selects the UserControl the first time, all controls have their bound data except for the RichTextBox that is empty. If the user selects another UserControl (i.e. loads another UserControl in the TransitionControl) and then re-selects this one, all controls including the RichTextBox have their bound data.

Since it is the same instance of the UserControl and all data is pre-loaded, the only difference between the first and second display of the UserControl is just that - the first and second time it is displayed through the TransitionControl. So, why isn't the RichTextBox content displayed the first time the UserControl is displayed?

Example of UserControl creation and Load method call:
iwAction iwu = new iwAction();
iwu.DataContext = this.DataContext;
iwu.Load("0");
this.twUserAction.Tag = iwu;

TransitionControl basics:
<telerik:RadTransitionControl x:Name="iwContent" Grid.Row="1" Duration="00:00:00.25" Content="{Binding SelectedItem.Tag, ElementName=IncidentTree}" Padding="5" Background="Transparent">

RichTextBox things...
<telerik:RadRichTextBox Grid.Row="4" x:Name="editor" Height="130" DocumentInheritsDefaultStyleSettings="True"
                                        Margin="3" Grid.Column="1">
    <telerik:RadRichTextBox.Resources>
        <telerikDocumentsHtml:HtmlDataProvider x:Key="HtmlProvider" RichTextBox="{Binding ElementName=editor}" Html="{Binding Body, Mode=TwoWay}" />
    </telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>

Since all other controls in the same UserControl bind to and display their data correctly on the first attempt, the load/bind functionality seems to be intact. It is only the RadRichTextBox that refuse to display the bound data on the first UserControl display but displays it correctly on subsequent displays.

Am I doing something wrong or is this a bug?

2 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 27 Apr 2011, 12:25 PM
Hello Gunnar,

There are some Silverlight binding issues with DataProviders (including HtmlDataProviders) with refreshing when data context is changed when the DataProvider is in the Resources of a control. One thing you could try is to add the provider directly to the visual tree (not to the resources) - it's not visible in any way, so this won't affect your visualization:

<Grid>
    ...
    <telerikDocumentsHtml:HtmlDataProvider RichTextBox="{Binding ElementName=editor}" Html="{Binding Body, Mode=TwoWay}" />
    <telerik:RadRichTextBox Grid.Row="4" x:Name="editor" Height="130" DocumentInheritsDefaultStyleSettings="True" Margin="3" Grid.Column="1">
    ...
</Grid>
Thus data binding should be updated properly when data context is changed.
There is also another option for you - to use HtmlFormatProvider in code, avoiding any binding obstacles.
Please get back to us if you experience further problems.

All the best,
Boby
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Gunnar
Top achievements
Rank 1
answered on 27 Apr 2011, 03:32 PM
Perfect.. Moving the HtmlDataProvider out of the Resources section solved the problem :-)
Thanks.

Tags
RichTextBox
Asked by
Gunnar
Top achievements
Rank 1
Answers by
Boby
Telerik team
Gunnar
Top achievements
Rank 1
Share this question
or