Default styles for RadRichTextBox

2 posts, 0 answers
  1. Steve
    Steve avatar
    7 posts
    Member since:
    Sep 2011

    Posted 30 Apr 2012 Link to this post


    I am using Telerik 2012 Q1 version for my silverlight radrichtextbox.

    The following is my xaml code

     <telerik:RadRichTextBox  Name="RichTextBoxNotificationText"  Grid.ColumnSpan="4" Grid.Row="19"  Margin="5,2,5,0" VerticalAlignment="Stretch" IsSpellCheckingEnabled="True"
                                             IsImageMiniToolBarEnabled="False" ScrollViewer.VerticalScrollBarVisibility="Visible" IsSelectionMiniToolBarEnabled="False" 
                                             DocumentInheritsDefaultStyleSettings="True" LayoutMode="Flow" VerticalScrollBarVisibility="Visible" TabIndex="{Binding DdlNotificationToFilerTextTabIndex}" telerikHtml:HtmlDataProvider.Source="{Binding NotificationText}"
                                             FontFamily="{StaticResource FontFamily}" FontSize="{StaticResource StandardFontSize}" FontStyle="{StaticResource FontStyle_Normal}" 
                                             Foreground="{StaticResource ForeGround}">
                            <telerik:RadDocument   LineSpacing="1" ParagraphDefaultSpacingAfter="0" ParagraphDefaultSpacingBefore="0" LineSpacingType="AtLeast"  />

    In ViewModel:

    If i assign:

    NotificationText = "New Value";

    It is not taking default font properties as assigned above.
    Please let me know how to remove the Telerik inbuilt styles and only take the styles which i am assiging using through static resource.

  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 03 May 2012 Link to this post

    Hello Steve,

    RadRichTextBox uses its default settings for FontFamily and FontSize when you open a new document or when you are showing plain text. If you open a .txt file, for example, or use TxtDataProvider to bind the content of the document, the default style settings will be used. However, if you import a rich text document, such as HTML, the font settings specified in the document will be used. If there are no explicit values for font size and font family, the default values of the format will be used. In the case of HTML that would be Times New Roman 11. This is the behavior by design, which ensures that the document will be shown as closest as possible to the way it would in a browser or Microsoft Word.

    If you want to load a rich text document, but alter the way it looks, you can handle the SetupDocument event and change the document as you see fit. You can find more information and some examples of using this event in this article. Note that the data providers create a new document every time the property they are bound to changes. Therefore, the settings you have declared on RadDocument in XAML will not be used. You can set them in the handler of the SetupDocument event.

    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top