RadRichTextBox default font size?

51 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Jul 2010

    Posted 27 Aug 2010 Link to this post

    Hi, does anyone know how to change the default font size for the RadRichTextBox?
    David
  2. Boby
    Admin
    Boby avatar
    595 posts

    Posted 01 Sep 2010 Link to this post

    Hello David,

    There are two approaches to this: in code-behind or in XAML. Below you can find examples, with sample font size of 32 dip (or 24 points):
    • RadDocument doc = new RadDocument();
      Section section = new Section();
       
      Paragraph paragraph = new Paragraph();
      paragraph.FontSize = 32;
       
      section.Paragraphs.Add(paragraph);
      doc.Sections.Add(section);
       
      this.radRichTextBox.Document = doc;
    • <telerik:RadRichTextBox x:Name="radRichTextBox">
          <telerik:RadRichTextBox.Document>
              <telerik:RadDocument>
                  <telerik:Section>
                      <telerik:Paragraph FontSize="32"/>
                  </telerik:Section>
              </telerik:RadDocument>
          </telerik:RadRichTextBox.Document>
      </telerik:RadRichTextBox>

    Best wishes,
    Boby
    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
  3. DevCraft banner
  4. Chen
    Chen avatar
    12 posts
    Member since:
    Jul 2010

    Posted 29 Oct 2010 Link to this post

    Hello Boby ,
    I tried these two ways. But they don't work. The default font size is not be changed. Here are my code followed. I use sivlerlight 4.0 and IE8.

    xmlns:telerikEditor="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents"
        xmlns:telerikEditorDocumentsModel="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents"
        xmlns:telerikEditorDocumentsUI="clr-namespace:Telerik.Windows.Documents.UI;assembly=Telerik.Windows.Documents"


    <Style x:Key="RadRichTextBoxStyle" TargetType="telerikEditor:RadRichTextBox">
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="Padding" Value="0"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="telerikEditor:RadRichTextBox">
                            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                                <Grid Background="{TemplateBinding Background}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <ContentControl x:Name="ViewPresenter"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

                                    <Border Background="Transparent" Grid.Column="1" Grid.Row="1"/>
                                    <ScrollBar x:Name="HorizontalScrollBar" Grid.Column="0" Height="16" IsTabStop="False" Minimum="0" Orientation="Horizontal" Grid.Row="1"/>
                                    <ScrollBar x:Name="VerticalScrollBar" Grid.Column="1" IsTabStop="False" Minimum="0" Orientation="Vertical" Grid.Row="0" Width="16"/>
                                    <Grid x:Name="PrintingScreen" Background="Transparent" Grid.ColumnSpan="2" Grid.RowSpan="2" Visibility="Collapsed">
                                        <TextBlock HorizontalAlignment="Center" Text="Printing..." VerticalAlignment="Center"/>
                                    </Grid>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>



    <telerikEditor:RadRichTextBox Grid.Row="1" x:Name="editor" MouseLeftButtonDown="editor_MouseLeftButtonDown"  LostMouseCapture="editor_LostFocus" BorderThickness="1" BorderBrush="Transparent" Margin="0"
                                          CurrentSpanStyleChanged="Editor_CurrentSpanStyleChanged"
                                          CurrentParagraphStyleChanged="Editor_CurrentParagraphPropertyChanged"
                                          Style="{StaticResource RadRichTextBoxStyle}" Grid.ColumnSpan="2">

                <telerikEditor:RadRichTextBox.Document>
                    <telerikEditorDocumentsModel:RadDocument>
                        <telerikEditorDocumentsModel:Section>
                            <telerikEditorDocumentsModel:Paragraph FontSize="36"/>
                        </telerikEditorDocumentsModel:Section>
                    </telerikEditorDocumentsModel:RadDocument>
                </telerikEditor:RadRichTextBox.Document>
                <telerikEditor:RadRichTextBox.Resources>
                    <Style TargetType="telerikEditorDocumentsUI:DocumentWebLayoutPresenter">
                        <Setter Property="Background" Value="Transparent" />
                    </Style>
                    <Style TargetType="telerikEditorDocumentsUI:DocumentPrintLayoutPresenter">
                        <Setter Property="Background" Value="Transparent" />
                    </Style>
                </telerikEditor:RadRichTextBox.Resources>
            </telerikEditor:RadRichTextBox>

    The C# codes are the same as yours. 

    Thanks.
    glchen

  5. Boby
    Admin
    Boby avatar
    595 posts

    Posted 29 Oct 2010 Link to this post

    Hi Chen,
    I have tested the code you provided and it changes the default font size correctly. In order to compile it, I deleted all statements that refer to event handlers in the code behind (MouseLeftButtonDown="editor_MouseLeftButtonDown",  LostMouseCapture="editor_LostFocus", CurrentSpanStyleChanged="Editor_CurrentSpanStyleChanged",                                   CurrentParagraphStyleChanged="Editor_CurrentParagraphPropertyChanged"), so I assume the problem is there.

    Feel free to get back to us if this doesn't help you solve your problem.

    Best wishes,
    Boby
    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
  6. namratha
    namratha avatar
    5 posts
    Member since:
    Nov 2010

    Posted 11 Nov 2010 Link to this post

    i  have used the code given 
    private void RadRibbonCombobox_selectionChanged()
    {
    RadDocument doc=new RadDocument();
    Section section=new Section();
    Paragraph paragraph=new Paragraph();
    section.Paragraphs.Add(paragraph);
    this.editor.Document=doc;
    }
    giving object ref not set to an instance
     private void RadRibbonComboBox_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
            {
                RadDocument doc = new RadDocument();
                Section section = new Section();

                Paragraph paragraph = new Paragraph();
                paragraph.FontSize = 32;

                section.Paragraphs.Add(paragraph);
                doc.Sections.Add(section);

                this.editor.Document = doc;
            }       
     private void RadRibbonComboBox_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
            {
                RadDocument doc = new RadDocument();
                Section section = new Section();

                Paragraph paragraph = new Paragraph();
                paragraph.FontSize = 32;

                section.Paragraphs.Add(paragraph);
                doc.Sections.Add(section);

                this.editor.Document = doc;
            }       
     private void RadRibbonComboBox_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
            {
                RadDocument doc = new RadDocument();
                Section section = new Section();

                Paragraph paragraph = new Paragraph();
                paragraph.FontSize = 32;

                section.Paragraphs.Add(paragraph);
                doc.Sections.Add(section);

      
     private void RadRibbonComboBox_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
            {
                RadDocument doc = new RadDocument();
                Section section = new Section();

                Paragraph paragraph = new Paragraph();
                paragraph.FontSize = 32;

                section.Paragraphs.Add(paragraph);
                doc.Sections.Add(section);

                this.editor.Document = doc;
            }       
             this.editor.Document = doc;
      
     private void RadRibbonComboBox_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
            {
                RadDocument doc = new RadDocument();
                Section section = new Section();

                Paragraph paragraph = new Paragraph();
                paragraph.FontSize = 32;

                section.Paragraphs.Add(paragraph);
                doc.Sections.Add(section);

                this.editor.Document = doc;
            }       
         }       
  7. Boby
    Admin
    Boby avatar
    595 posts

    Posted 12 Nov 2010 Link to this post

    Hello Namratha,
    In case you are using Q3 2010 version of control, you should use newly introduced Blocks property of the Section class:
    private void RadRibbonCombobox_selectionChanged()
    {
        RadDocument doc = new RadDocument();
        Section section = new Section();
        Paragraph paragraph = new Paragraph();
        section.Blocks.Add(paragraph);
        this.editor.Document = doc;
    }
    Besides, we decided to implement properties for changing the default font family and font size of the document, so if this is your case the previous workaround is not needed anymore. You could use the new propeprties directly from XAML (or from code-behind), as in the following example (it will set the font family to Courier New and the font size to 32 dip (or 24 points)):
    <telerik:RadRichTextBox Name="radRichTextBox" DocumentInheritsDefaultStyleSettings="True" FontFamily="Courier New" FontSize="32" />

    Don't hesitate to contact us if you have other questions.


    Kind regards,
    Boby
    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
  8. namratha
    namratha avatar
    5 posts
    Member since:
    Nov 2010

    Posted 18 Nov 2010 Link to this post

    hi thanks for your reply,actually i am using Q2 version and i am getting the text center aligned but i want it to be left aligned and i am getting scroll bars.i am not getting the normal word format

    <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
          <Grid.RowDefinitions>
              <RowDefinition Height="47" />
              <RowDefinition Height="265" />
          </Grid.RowDefinitions>
          <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
              <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
              <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
              <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
              <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
          </StackPanel>
          <StackPanel Margin="0,0,5,59" Grid.Row="1">
              <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                   
     
              </telerik:RadRichTextBox>
          </StackPanel>
      </Grid>

      <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
            <Grid.RowDefinitions>
                <RowDefinition Height="47" />
                <RowDefinition Height="265" />
            </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
                <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
                <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
            </StackPanel>
            <StackPanel Margin="0,0,5,59" Grid.Row="1">
                <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                    

                </telerik:RadRichTextBox>
            </StackPanel>
        </Grid>
    and details.xaml.cs:
      private void btnBold_Checked(object sender, RoutedEventArgs e)
            {
     this.editor.ToggleBold();
            }

            private void btnItalic_Checked(object sender, RoutedEventArgs e)
            {
       this.editor.ToggleItalic();
         
            }

            private void btnUnderline_Checked(object sender, RoutedEventArgs e)
            {
                this.editor.ToggleUnderline();
            }

            /// <summary>
            /// Insertlink
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void RadRibbonButton_Click(object sender, RoutedEventArgs e)
            {
                InsertLinkWindow dialog = new InsertLinkWindow(this.editor);
                dialog.ShowDialog();

            }

    private void btnBold_Checked(object sender, RoutedEventArgs e)
           {
    this.editor.ToggleBold();
           }
     
           private void btnItalic_Checked(object sender, RoutedEventArgs e)
           {
      this.editor.ToggleItalic();
         
           }
     
           private void btnUnderline_Checked(object sender, RoutedEventArgs e)
           {
               this.editor.ToggleUnderline();
           }
     
           /// <summary>
           /// Insertlink
           /// </summary>
           /// <param name="sender"></param>
           /// <param name="e"></param>
           private void RadRibbonButton_Click(object sender, RoutedEventArgs e)
           {
               InsertLinkWindow dialog = new InsertLinkWindow(this.editor);
               dialog.ShowDialog();
     
           }

      <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
            <Grid.RowDefinitions>
                <RowDefinition Height="47" />
                <RowDefinition Height="265" />
            </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
                <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
                <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
      this       </StackPanel>
            <StackPanel Margin="0,0,5,59" Grid.Row="1">
                <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                    

                </telerik:RadRichTextBox>
            </StackPanel>
        </Grid>
    this is user control and i am importing data and displaying in main page
    /// <summary>
         /// RadDocument CreateRadDocument
         /// </summary>
         /// <param name="content"></param>
         /// <returns></returns>
         private RadDocument CreateRadDocument(string content)
         {
             HtmlFormatProvider provider = new HtmlFormatProvider();         
             RadDocument document;
             using (MemoryStream stream = new MemoryStream())
             {
                 StreamWriter writer = new StreamWriter(stream);
                 writer.Write(content);
                 writer.Flush();
                 stream.Seek(0, SeekOrigin.Begin);
                 document = provider.Import(stream);
             }
             return document;
         }
     
         public string ExportToHtml(RadDocument document)
         {
             IDocumentFormatProvider provider = new HtmlFormatProvider();
             string exportValue = String.Empty;
             using (MemoryStream output = new MemoryStream())
             {
                 provider.Export(document, output);
                 output.Seek(0, SeekOrigin.Begin);
                 using (StreamReader reader = new StreamReader(output))
                 {
                     exportValue = reader.ReadToEnd();
                 }
             }
             return exportValue;
         }

    rtbDetails.editor.Document = CreateRadDocument(e.emailList.mContent);
     
    ///rtbDetails.editor.Document
    ///here rtbDetails is usercontrol name and editor is my richtextbox
    please help me its urgent i am not able to get the body content in exact fashion


    rtbDetails.editor.Document = CreateRadDocument(e.emailList.mContent);
     
    ///rtbDetails.editor.Document
    ///here rtbDetails is usercontrol name and editor is my richtextbox
    please help me its urgent i am not able to get the body content in exact fashion

    cSpEmail.mContent = ExportToHtml(rtbDetails.editor.Document);
    ///cSpEmail.mContent is data member name which acts as email body in my send email functionality





      xmlns:telerikDocuments="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents"
    xmlns:telerikDocumentsModel="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents"
      xmlns:telerikDocuments="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents"
    xmlns:telerikDocumentsModel="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents"

    i am not able to access property
    DocumentInheritsDefaultStyleSettings="True" though i have added the above namespaces


    Thanks in advance,
    namratha

      <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
            <Grid.RowDefinitions>
                <RowDefinition Height="47" />
                <RowDefinition Height="265" />
            </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
                <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
      


              <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
            </StackPanel>
            <StackPanel Margin="0,0,5,59" Grid.Row="1">
                <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                    

                </telerik:RadRichTextBox>
            </StackPanel>
        </Grid>
      <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
            <Grid.RowDefinitions>
                <RowDefinition Height="47" />
                <RowDefinition Height="265" />
            </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
                <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
      
    cSpEmail.mContent = ExportToHtml(rtbDetails.editor.Document);
    ///here cSpEmail.mContent is my datacontract name
    cSpEmail.mContent = ExportToHtml(rtbDetails.editor.Document);
    ///cSpEmail.mContent is data member name which acts as email body in my send email functionality
             <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
            </StackPanel>
            <StackPanel Margin="0,0,5,59" Grid.Row="1">
                <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                    

                </telerik:RadRichTextBox>
            </StackPanel>
        </Grid>
      <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
            <Grid.RowDefinitions>
                <RowDefinition Height="47" />
                <RowDefinition Height="265" />
            </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
                <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
                <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
            </StackPanel>
            <StackPanel Margin="0,0,5,59" Grid.Row="1">
                <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                    

                </telerik:RadRichTextBox>
            </StackPanel>
        </Grid>
      <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
            <Grid.RowDefinitions>
                <RowDefinition Height="47" />
                <RowDefinition Height="265" />
            </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
                <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
                <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
            </StackPanel>
      
    <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
          <Grid.RowDefinitions>
              <RowDefinition Height="47" />
              <RowDefinition Height="265" />
          </Grid.RowDefinitions>
          <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
              <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
              <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
              <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
              <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
          </StackPanel>
          <StackPanel Margin="0,0,5,59" Grid.Row="1">
              <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                   
     
              </telerik:RadRichTextBox>
          </StackPanel>
      </Grid>
         <StackPanel Margin="0,0,5,59" Grid.Row="1">
                <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                    

                </telerik:RadRichTextBox>
            </StackPanel>
        </Grid>
      <Grid x:Name="LayoutRoot" Background="White" Margin="0,0,0,0" Width="539">
            <Grid.RowDefinitions>
                <RowDefinition Height="47" />
                <RowDefinition Height="265" />
            </Grid.RowDefinitions>
            <StackPanel HorizontalAlignment="Left" Margin="0,8,0,8" Width="149" Orientation="Horizontal">
                <ToggleButton HorizontalAlignment="Left" Name="btnBold" Height="27" Margin="0,0,0,0" Width="28" Content="B" Checked="btnBold_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnItalic" Height="27" Margin="0,0,0,0" Width="28" Content="I" Checked="btnItalic_Checked" />
                <ToggleButton HorizontalAlignment="Left" Name="btnUnderline" Height="27" Margin="0,0,0,0" Width="28" Content="U" Checked="btnUnderline_Checked" />
                <telerik:RadRibbonButton HorizontalAlignment="Left" Height="27" HorizontalContentAlignment="Left" Margin="0,0,0,0" Width="138" Content="Insert Link" Click="RadRibbonButton_Click" />
            </StackPanel>
            <StackPanel Margin="0,0,5,59" Grid.Row="1">
                <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left">
                    

                </telerik:RadRichTextBox>
            </StackPanel>
        </Grid>

     
  9. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 19 Nov 2010 Link to this post

    Hi namratha,

    It is not RadRichTextBox that is not centered, but your Grid. Either remove the setter for the Grid's Width property (Width="539") or set its property HorizontalAlignment="Left".

    If you want to have pages similar to those you normally see in Word, you have to set the LayoutMode property of the document to Flow like this:

    <telerik:RadRichTextBox Name="editor" Height="221" Margin="0,2" Width="539" VerticalAlignment="Top" HorizontalAlignment="Left" >
        <telerik:RadRichTextBox.Document>
             <telerik:RadDocument LayoutMode="Flow" />
        </telerik:RadRichTextBox.Document>
    </telerik:RadRichTextBox>

    As for the property DocumentInheritsDefaultStyleSettings, it was introduced in Q3 2010, so you cannot use it unless you upgrade to that version of RadRichTextBox.

    Sincerely yours,
    Iva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  10. Michael Montgomery
    Michael Montgomery avatar
    4 posts
    Member since:
    Feb 2010

    Posted 20 Nov 2010 Link to this post

    This code is not working to establish the default family and size. Can you please point out specifically how to set the default family and size. Thank you!

            <telerik1:RadRichTextBox x:Name="DescriptionRichTextBox" DocumentInheritsDefaultStyleSettings="True" FontFamily="Arial" FontSize="53" >
                <telerik1:RadRichTextBox.Resources>
                    <Html:HtmlDataProvider x:Key="HtmlProvider" RichTextBox="{Binding ElementName=DescriptionRichTextBox}" Html="test" />
                </telerik1:RadRichTextBox.Resources>
            </telerik1:RadRichTextBox>

  11. Boby
    Admin
    Boby avatar
    595 posts

    Posted 22 Nov 2010 Link to this post

    Hello Michael Montgomery,
    When you bind RadRichTextBox to a data source, HtmlDataProvider (as well as the other providers) generates instance of RadDocument based on the data in the data source and set it to the Document property of RadRichTextBox. Thus values for font and font family from this document takes precedence over the values set in RadRichTextBox.
    We consider this normal behavior as default values should never override explicit ones.
    In your case, you have two options:
    1.  Change the data in your data source - if you want to show the document with font size of 53 for all spans, just save it that way.
    2. Modify the document created from the data source before its passing to the RadRichTextBox, by subscribing to the SetupDocument event of HtmlDataProvider:
      <Html:HtmlDataProvider x:Key="HtmlProvider" RichTextBox="{Binding ElementName=DescriptionRichTextBox}" Html="test" SetupDocument="HtmlDataProvider_SetupDocument" />
      private void HtmlDataProvider_SetupDocument(object sender, SetupDocumentEventArgs e)
      {
         // edit the document in e.Document here
      }

    Don't hesitate to contact us if you have other questions.

    Best wishes,
    Boby
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  12. Michael Montgomery
    Michael Montgomery avatar
    4 posts
    Member since:
    Feb 2010

    Posted 22 Nov 2010 Link to this post

    These concepts and techniques are well understood however, a new feature of the control is supposed to be "Properties for setting default Document/RichTextBox font family, font size". the values from the document should take precedence, but if there are no font and size specifications, shouldn't the control use the new "default Document/RichTextBox font family, font size" feature.

    In my scenario, I've just got existing, basic HTML that I need to display. It does not contain any font or size specifications and I don't want it to. I want it to display using the DEFAULTS. Preferably without having to wire any events.

    Thank you!
  13. Boby
    Admin
    Boby avatar
    595 posts

    Posted 23 Nov 2010 Link to this post

    Hello Michael Montgomery,
    RadRichTextBox's default values for font style (FontFamily, FontSize, etc. ) are applied to the RadDocument in the Document property only if it's empty. In your case, HtmlFormatProvider creates document and sets its formatting properties according to HTML specification (Times New Roman, 12). However, we will consider changing this behavior to the one you proposed, and will implement it in the next minor release if find it appropriate. As a workaround, you can clear font style properties of all spans, thus they will inherit the latter from the RadRichTextBox:
    private void HtmlDataProvider_SetupDocument(object sender, SetupDocumentEventArgs e)
    {
        foreach (Span span in e.Document.EnumerateChildrenOfType<Span>())
        {
            span.ClearValue(Span.FontSizeProperty);
            span.ClearValue(Span.FontFamilyProperty);
            span.ClearValue(Span.FontStyleProperty);
            span.ClearValue(Span.FontWeightProperty);
        }
    }

    In order to avoid subscribing to events in your view, you can use behaviors, as demonstrated in the attached sample project, which is completely code-behindless.

    Greetings,
    Boby
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  14. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 01 Dec 2010 Link to this post

    Hello,

    I'm using the RIchTextBox with the RichTextBoxRibbonUI and I need to set the default FontSize to 10. How can I do it? I've tried to set DocumentsInheritDefaultStyle to true but then FontFamily and FontSize Ribbon's ComboBoxes appear empty. Also tried to set SelectedIndex=2 in FontSize comobobox, with no result. Can anyone hekp me?
  15. Boby
    Admin
    Boby avatar
    595 posts

    Posted 01 Dec 2010 Link to this post

    Hello Daní,
    The default font for Control class (which is base for RadRichTextBoxRibbonUI) is "Portable User Interface".  With setting of DocumentInheritsDefaultStyleSettings this font is inherited by document. Since such item is not included in the items of font size combobox, it is not visualized. This is known limitation, and fixing it is in our to-do list.
    I think your best option for now is to set Font property explicitly to "Lucida Sans Unicode", for which "Portable User Interface" is alias in case of non-East Asian cultures. This way the font family will appear in the combo.
    To work around this for font size combo, you can set font size to some of the values that are included in the combo, closest being 10.66 dips (which is 8 points):
    <telerik:RadRichTextBox DocumentInheritsDefaultStyleSettings="True" FontFamily="Lucida Sans Unicode" FontSize="10.66" />
    We are sorry for the inconvenience.

    All the best,
    Boby
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  16. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 01 Dec 2010 Link to this post

    Hi Boby,

    Is not running for me:

    <telerik:RadRichTextBox IsSelectionMiniToolBarEnabled="True" DocumentInheritsDefaultStyleSettings="True" FontFamily="Verdana" FontSize="13.33" IsSpellCheckingEnabled="False" x:Name="richTextBox" Grid.Row="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>

    I expect to see Verdana selected in the FontFamily selector and 10 in the FontSize selector, but both are empty.
  17. Boby
    Admin
    Boby avatar
    595 posts

    Posted 02 Dec 2010 Link to this post

    Hello Daní,
    Could you please verify version of the controls you are using?
    We have tested this with Q3 2010 and it works as you expected. I am attaching working sample project to check this on your side - I omitted setting some of the properties of RadRichTextBox like in your example, since they were with their default values.

    Sincerely yours,
    Boby
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  18. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 02 Dec 2010 Link to this post

    Hi Boby,

    I'm getting crazy with this topic!!!!!!!

    Telerik dll's version is right, 2010.3.1110.1040, and your solution is working right for me, but not mine's. I don't know why, maybe the reason is the container where the RichtTextbox + RichtTextBobRibbonBarUI are placed in, it's a custom content control taht ensures the content has the samse size as the container. It's strange, because all is working right...

    I addition, playing with the FontFamily and FontSize selectors it's a sort of nightmare, when changing FontFamily or FontSize, often they back to the previous value (with both selectors empty).

    I'll try to build a demo to reproduce this issue (entire solution is too big) and I'll upload it.
  19. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 02 Dec 2010 Link to this post

    Hi Boby,

    Effectively, my custom ContentControl is causing the issue, I have modified your solution so the LayoutRoot is the content of my custom control and the issue is reproduced. How can I upload this solution to you?
  20. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 03 Dec 2010 Link to this post

    Hi Daní,

    We received your support ticket already. We'll be continuing our conversation there.

    Kind regards,

    Iva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  21. Kirk Quinbar
    Kirk Quinbar avatar
    48 posts
    Member since:
    Nov 2007

    Posted 09 Dec 2010 Link to this post

    hi,

    1. I am having similar issues as in this posting with font family and also foreground color. assuming the same type of binding as above, even if i change Foreground on the richtextbox, the foreground color of the text in the editor remains black. Is this because the default text color is always black instead of using what the richtextbox.foreground color is? can this also be considered for change so that if there isnt a color defined in the imported html, that it will just use richtextbox.Foreground as the default color?

    2. you say above "In your case, HtmlFormatProvider creates document and sets its formatting properties according to HTML specification (Times New Roman, 12). However, we will consider changing this behavior to the one you proposed, and will implement it in the next minor release if find it appropriate.". was this default behavior considered an appropriate change or are you still in review?

    Kirk
  22. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 11 Dec 2010 Link to this post

    Hi Kirk Quinbar,

    RadRichTextBox currently does not support default properties for foreground or background colors. The properties that are included in the defaults, which DocumentInheritsDefaultStyleSettings = true ensures, are:

    • FontFamily;
    • FontSize;
    • FontStyle;
    • FontWeight.
    We might consider adding some others, but it is not currently on our to-do list.
     A workaround (if you're creating an empty document and not importing the content using a format provider) might be:
    private void radRichTextBox1_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        Dispatcher.BeginInvoke(() =>
        {
            Paragraph p = this.radRichTextBox1.Document.Sections.First.Blocks.First as Paragraph;
            if (p == null)
            {
                p = new Paragraph();
                this.radRichTextBox1.Document.Sections.First.Blocks.Add(p);
            }
            Span span = p.Inlines.First as Span;
            span.ForeColor = Colors.Green;
        });
    }

     As it comes to the FontFamily issue, I am assuming that you are using HtmlFormatProvider to import a document and therefore, the default property set on RadRichTextBox is not being respected. We have decided to change this behavior and will try to squeeze it in for Service Pack 1, which is due in a week or so, but I cannot guarantee that for sure.

    Regards, Iva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  23. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 22 Dec 2010 Link to this post

    Dear Sir,

              I am Using radrichtext box, I need to create a report from rad document and also i tried to add a radrichtextbox in silverlight dataGrid, i cannot able to bind rad document to it.because HTMLDATAProvider is not recognized because i am using older version. how can i get a latest version. Please help me.

    Thank You!
  24. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 23 Dec 2010 Link to this post

    Hello Uthaya,

     When you log in to your account at http://www.telerik.com/login.aspx?ReturnUrl=/account.aspx, in the top-right corner, click "Your account". Then, you can choose whether to download a free trial or buy the products ("Download and Manage your products"). 
    In the internal builds downloads in the bottom-right corner of your account's page you can find the latest version.

    Regards,
    Iva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  25. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 23 Dec 2010 Link to this post

    Thank You Sir,
                   
                  Is it Possible to buy only richtextbox alone?
  26. Donna
    Admin
    Donna avatar
    67 posts

    Posted 27 Dec 2010 Link to this post

    Hi David,

    Individual controls are not offered separately, which means that in order for you to get the RadRichTextBox, you will need to purchase a license for the entire Silverlight suite.
     
    We have two types of licenses for the RadControls for Silverlight suite and they are as follows:
     
    -      RadControls for Silverlight Developer license without subscription - $799/developer. This license comes with free minor product updates and Standard Level Support (48h guaranteed response time, Mon-Fri) for 1 year, and does not offer source code.
     
    -      RadControls for Silverlight Developer License with Subscription and Priority Support - $999/developer. With the subscription license you will be entitled to receive all version updates (major and minor) for the Software for a period of 1 year. As part of this license you will be also entitled to a Priority Level Support (24h guaranteed response time, Mon-Fri). And last, but not least the subscription license grants access to the full C# and JavaScript source code.

    I hope this works for you. Please let me know how you'd like to proceed.
     
    Greetings,
    Donna
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  27. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 30 Dec 2010 Link to this post

    Thanks, but I am a student just my college project i was used radrichtextbox only in my project. so I dont want these much of contols now. If I want. I will get back. Now please clear one more doubt for me. how to make a report from radrichtextbox content?
  28. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 03 Jan 2011 Link to this post

    Hi Uthaya,

    You can use the FormatProviders that RadRichTextBox has to export documents in HTML, DOCX, XAML, PDF and TXT format. You can refer to our help section for examples on how you can do that.
    If you want to show the report in Telerik reporting, then you need to use HtmlFormatProvider with the folowing settings:

    • StylesExportMode = Inline
    • DocumentExportLevel = Fragment. 
    If you have pictures in your HTML files, they will also not be loaded in Telerik reporting.

    Best wishes,


    Iva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight

  29. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 06 Jan 2011 Link to this post

    Thanks, But I am using  radrichtextbox as a silverlight datagrid column, so I need to bind the radrichtextbox document to that datagird coumn. what can i do?
  30. Mike
    Admin
    Mike avatar
    640 posts

    Posted 10 Jan 2011 Link to this post

    Hi David,

    Here is an example of using RadRichTextBox in a DataGrid. In this case the Grid is bound to data items with have a "Memo" property, and format of the data is Html:
    The namespaces you should add to the user control:

               xmlns:telerikHtml="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents.FormatProviders.Html"
               xmlns:telerikHtmlSettings="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents"
    DataGrid Texmplate Column Xaml:
    <my:DataGridTemplateColumn Header="Memo" Width="200">
        <my:DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <telerik:RadRichTextBox Height="50" x:Name="GridRichTextBox" IsSpellCheckingEnabled="False" IsSelectionEnabled="False" FontSize="10" IsReadOnly="True" IsFocusable="False" IsHitTestVisible="False">
                    <telerik:RadRichTextBox.Resources>
                        <telerikHtml:HtmlDataProvider x:Key="HtmlProvider" RichTextBox="{Binding ElementName=GridRichTextBox}" Html="{Binding Memo, Mode=TwoWay}" >
                            <telerikHtml:HtmlDataProvider.FormatProvider>
                                <telerikHtml:HtmlFormatProvider>
                                    <telerikHtml:HtmlFormatProvider.ExportSettings>
                                        <telerikHtmlSettings:HtmlExportSettings DocumentExportLevel="Document" StylesExportMode="Inline" />
                                    </telerikHtml:HtmlFormatProvider.ExportSettings>
                                </telerikHtml:HtmlFormatProvider>
                            </telerikHtml:HtmlDataProvider.FormatProvider>
                        </telerikHtml:HtmlDataProvider>
                    </telerik:RadRichTextBox.Resources>
                </telerik:RadRichTextBox>          
            </DataTemplate>
        </my:DataGridTemplateColumn.CellTemplate>
        <my:DataGridTemplateColumn.CellEditingTemplate>
            <DataTemplate>
                <telerik:RadRichTextBox Height="50" x:Name="GridRichTextBox" FontSize="10">
                    <telerik:RadRichTextBox.Resources>
                        <telerikHtml:HtmlDataProvider x:Key="HtmlProvider" RichTextBox="{Binding ElementName=GridRichTextBox}" Html="{Binding Memo, Mode=TwoWay}" />
                    </telerik:RadRichTextBox.Resources>
                </telerik:RadRichTextBox>          
            </DataTemplate>
        </my:DataGridTemplateColumn.CellEditingTemplate>
    </my:DataGridTemplateColumn>
    In this case the HtmlDataProvider is used but you can change it very easy to say XamlDataProvider if you prefer to store the data as Xaml.

    Let us know if this helps.

    All the best,
    Mike
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  31. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 11 Jan 2011 Link to this post

    Thanks, But I was added the all Namespaces, but still HTMLDataProvider and HtmlExportSettings classes only not found. Ok, Is anyother way to add radrichtextbox in data grid? Else Shall we take a print out from rad document?
Back to Top
DevCraft banner