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

RadRichTextBox in BackstageItem

1 Answer 63 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 25 Sep 2012, 08:43 AM
Hello,

i'm trying to bind a xaml document to my radrichtextbox which is situated in a backstageitem. This doesn't want to work. 
Below you can see the code i use in my backstageitem, the CurrentPatchnotes is situated in the datacontext of a contentcontrol in the backstageitem. The textblock shows the value correctly (when uncommented ofc) yet the richtextbox won't show a thing.


                                                <Grid Grid.Row="1" Height="400">
                                                    <!--<TextBlock Text="{Binding CurrentPatchNotes, UpdateSourceTrigger=PropertyChanged}"/>-->
                                                    <telerik:XamlDataProvider RichTextBox="{Binding ElementName = Viewer}" Xaml="{Binding CurrentPatchNotes, UpdateSourceTrigger=PropertyChanged}" />
                                                    <telerik:RadRichTextBox IsSpellCheckingEnabled="False" x:Name="Viewer" IsReadOnly="True"/>
                                                </Grid>


Someone has any experience with this?

Thank you in advance

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 27 Sep 2012, 08:11 AM
Hi Mike,

The problem you experience is specific and it is related to the fact that the RadRichTextBox and the data providers are not part of the visual tree when put in the Backstage of RadRibbonView. Therefore, the ElementName binding cannot be resolved. Fortunately, there is another way that you could bind the data provider to the rich text box in order to fix this behavior and it consists of replacing the reference by ElementName in the binding of the RichTextBox property of XamlDataProvider with a Source Reference:

<telerik:XamlDataProvider x:Name="ViewerProvider" Grid.Row="0" RichTextBox="{Binding Source={x:Reference Viewer}}" Xaml="{Binding CurrentPatchNotes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

For more information check this blogpost.  

Note that this is possible only in WPF 4.0 and will not be handled correctly by the designer. As described by Adam Nathan in "WPF 4 Unleashed":

One glitch is that the XAML designer in Visual Studio 2010 doesn’t properly handle x:Reference, so it gives the following design-time error that you can safely ignore:
  
"Service provider is missing the INameResolver service."

I hope this helps.


Regards,
Martin
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Tags
RichTextBox
Asked by
Mike
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or