Styling documents when data bound

2 posts, 1 answers
  1. Emil Einarsson
    Emil Einarsson avatar
    18 posts
    Member since:
    Apr 2010

    Posted 03 May 2011 Link to this post


    I have a RichTextBox and it's source is bound via a DataProvider. However, I want to set some properties on the RadDocument to change the visual experience. But the document is created on the fly when using databinding.

    So I tried to do this:

    <Style TargetType="Model:RadDocument">
       <Setter Property="LayoutMode" Value="Flow"/>
       <Setter Property="SectionDefaultPageMargin" Value="0"/>

    But it didnt work. How can I restyle the document when using databinding?

  2. Answer
    Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 05 May 2011 Link to this post

    Hello Emil Einarsson,

    You can use the SetupDocument event of RtfDataProvider (actually it comes from DataProviderBase, so all of the data providers have it) to set the properties of the document. Here is an example:

    private void RtfDataProvider_SetupDocument(objectsender, Telerik.Windows.Documents.FormatProviders.SetupDocumentEventArgs e)
          //e.Document.LayoutMode = Telerik.Windows.Documents.Model.DocumentLayoutMode.Paged;
          e.Document.SectionDefaultPageMargin = newPadding(0);

    However, if you set the property LayoutMode on the rich text box, you can skip setting it in the handler for SetupDocument.

    All the best,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top