RadRichTextBox in BackstageItem

2 posts, 1 answers
  1. Mike
    Mike avatar
    3 posts
    Member since:
    Dec 2011

    Posted 25 Sep 2012 Link to this post


    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"/>

    Someone has any experience with this?

    Thank you in advance
  2. Answer
    Martin Ivanov
    Martin Ivanov avatar
    104 posts

    Posted 27 Sep 2012 Link to this post

    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.

    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top