XamlDatProvider error

2 posts, 1 answers
  1. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 28 Jun 2013 Link to this post

    Getting an odd error I can't run to ground when binding a RichTextBox to a database via MVVM. here's my simple code:

    <Grid x:Name="LayoutRoot"
            Margin=" 10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <telerik:RadListBox x:Name="ToC"
                                ItemsSource="{Binding HelpDocs}"
                                SelectedItem="{Binding SelectedTopic, Mode=TwoWay}"/>
        <telerik:XamlDataProvider x:Name="CurrentDocument"
                                    RichTextBox="{Binding SelectedTopic.Body}"
                                    Xaml="{Binding SelectedTopic.Body, Mode=TwoWay}"/>
        <telerik:RadRichTextBox x:Name="HelpPane"
                                Grid.Column="1"
                                LayoutMode="Flow"
                                IsReadOnly="False"
                                IsSpellCheckingEnabled="False"
                                ScrollViewer.VerticalScrollBarVisibility="Auto"
                                Background="{x:Null}"
                                BorderBrush="{x:Null}"
                                BorderThickness="0"
                                Grid.ColumnSpan="2"/>
    </Grid>

    The RichTextBox binding of the XamlDataProvider throws the following error:

    The local property "RichTextBox" can only be applied to types that are derived from "DataProviderBase".

    What am I missing?

  2. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 01 Jul 2013 Link to this post

    Hi Art,

    It seems that the problem is with the way you have set the RichTextBox property of XamlDataProvider:

    RichTextBox="{Binding SelectedTopic.Body}"

    Judging from the rest of the code, this SelectedTopic.Body must be the property that keeps the content of the document as a XAML string. The RichTextBox property, however, is the link between the provider and the RadRichTextBox, so it should be bound to the RadRichTextBox instance like this:

    RichTextBox="{Binding ElementName="HelpPane"}"

    More information on data providers can be found here.


    Regards,
    Iva Toteva
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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 >>
  3. DevCraft banner
Back to Top