Binding RichTextBox in Book

4 posts, 1 answers
  1. o
    o avatar
    20 posts
    Member since:
    Jan 2008

    Posted 15 Sep 2013 Link to this post

    Helooo,

    I have RadBook that contain richtextbox that I want to Bind data to,

    My Book Data Template is :

    <DataTemplate x:Key  ="LeftPageTemplate"   >
               <StackPanel Margin="10" Background="Azure" >
               <Viewbox Name="ViewSura" Stretch="Fill"        StretchDirection="Both"          FlowDirection="RightToLeft"
                     HorizontalAlignment="Left" Width="450"  Margin="525,21,0,0" Height="600" VerticalAlignment="Top">
                   <RichTextBox FontSize="22" MaxWidth ="450" MaxHeight ="600"   Name="richTextBox1"
                                Document ="{Binding FLD}" VerticalAlignment="Top"
                                Background="Brown"  FontStretch="Condensed"
                                FontFamily="KFGQPC Uthmanic Script HAFS" >
                       <RichTextBox.Resources>
                           <Style TargetType="Run">
                               <EventSetter Event="MouseLeftButtonDown"  />
                           </Style>
                       </RichTextBox.Resources>
                   </RichTextBox >
               </Viewbox>
           </StackPanel>
           </DataTemplate>

    In in my code Page XML File:

    <Window.Resources>
           <ResourceDictionary>
               <ResourceDictionary.MergedDictionaries>
                   <ResourceDictionary Source="Dictionary1.xaml"></ResourceDictionary>
               </ResourceDictionary.MergedDictionaries>
           </ResourceDictionary>
       </Window.Resources>
       <Grid>
       <telerik:RadBook x:Name="RadBook1"
                        Margin="50"
                        LeftPageTemplate="{StaticResource LeftPageTemplate}"
                        RightPageTemplate="{StaticResource RightPageTemplate}" />

    In in my C# code I did this:

    ObservableCollection<RTBI > MyPages= new ObservableCollection<RTBI>();
            
              for (int i = 0; i < 10; i = i + 1)
              {
                  ReadSura rs = new ReadSura();
     
                  MyPages.Add(new RTBI()
                  {
                      FLD = rs.readsuratxt(i + 1) //  This is to get the Flow document ..
                  });
              }
              RadBook1.ItemsSource = MyPages ;
          }

    Put I get the error for binding, please what am I doing wrong. Please see the attached image for error details.

    Please Help.

    Regards...


  2. o
    o avatar
    20 posts
    Member since:
    Jan 2008

    Posted 16 Sep 2013 Link to this post

    Any help Please....
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 18 Sep 2013 Link to this post

    Hello,

    RadRichTextBox's Document property is not a DependencyProperty so binding such as the one you've implemented is not possible. For the purpose of data binding documents to the editor Data Providers are exposed. 

    Further, in order to bind to Items controls RadDocumentBindingSource was introduced. There is also a corresponding RichTextPageViewPresenter. You can see how they work in one of RadRichTextBox's click-once demos RadBook Integration as well as in the attached sample project.

    Note that the integration between the two controls has some known issues, however at this point they are not scheduled.

    I hope this helps!

    Regards,
    Petya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    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 >>
  5. o
    o avatar
    20 posts
    Member since:
    Jan 2008

    Posted 18 Sep 2013 Link to this post

    Many Thanks,

    Unfortunately I do not have the 2010 release which do not have the new features.

    Best Regards,
    Omar
Back to Top