This is a migrated thread and some comments may be shown as answers.
XamlDatProvider error
1 Answer 19 Views
This is a migrated thread and some comments may be shown as answers.
Art Kedzierski
Top achievements
Rank 2
Art Kedzierski asked on 28 Jun 2013, 08:04 PM
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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 01 Jul 2013, 10:48 AM
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 >>
Asked by
Art Kedzierski
Top achievements
Rank 2
Answers by
Iva Toteva
Telerik team
Share this question
or