This is a migrated thread and some comments may be shown as answers.

RadRichTextBox default font size?

50 Answers 1323 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 28 Aug 2010, 12:09 AM
Hi, does anyone know how to change the default font size for the RadRichTextBox?
David

50 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 01 Sep 2010, 02:18 PM
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
0
Chen
Top achievements
Rank 1
answered on 29 Oct 2010, 06:52 AM

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

0
Boby
Telerik team
answered on 29 Oct 2010, 09:47 AM
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
0
namratha
Top achievements
Rank 2
answered on 11 Nov 2010, 12:04 PM
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;
        }       
     }       
0
Boby
Telerik team
answered on 12 Nov 2010, 09:52 AM
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
0
namratha
Top achievements
Rank 2
answered on 18 Nov 2010, 06:49 AM
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>

 
0
Iva Toteva
Telerik team
answered on 19 Nov 2010, 05:15 PM
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
0
Michael Montgomery
Top achievements
Rank 1
answered on 21 Nov 2010, 12:15 AM

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>

0
Boby
Telerik team
answered on 22 Nov 2010, 03:27 PM
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
0
Michael Montgomery
Top achievements
Rank 1
answered on 22 Nov 2010, 03:47 PM
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!
0
Boby
Telerik team
answered on 23 Nov 2010, 03:21 PM
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
0
Daní
Top achievements
Rank 1
answered on 01 Dec 2010, 11:23 AM
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?
0
Boby
Telerik team
answered on 01 Dec 2010, 02:35 PM
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
0
Daní
Top achievements
Rank 1
answered on 01 Dec 2010, 02:49 PM

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.
0
Boby
Telerik team
answered on 02 Dec 2010, 09:10 AM
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
0
Daní
Top achievements
Rank 1
answered on 02 Dec 2010, 04:44 PM
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.
0
Daní
Top achievements
Rank 1
answered on 02 Dec 2010, 06:19 PM
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?
0
Iva Toteva
Telerik team
answered on 03 Dec 2010, 06:36 PM
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
0
Kirk Quinbar
Top achievements
Rank 1
answered on 09 Dec 2010, 03:23 PM
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
0
Iva Toteva
Telerik team
answered on 11 Dec 2010, 09:10 AM
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
0
uthaya
Top achievements
Rank 1
answered on 22 Dec 2010, 08:27 AM
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!
0
Iva Toteva
Telerik team
answered on 23 Dec 2010, 01:38 PM
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
0
uthaya
Top achievements
Rank 1
answered on 23 Dec 2010, 03:37 PM
Thank You Sir,
               
              Is it Possible to buy only richtextbox alone?
0
Donna
Telerik team
answered on 27 Dec 2010, 03:57 PM
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
0
uthaya
Top achievements
Rank 1
answered on 30 Dec 2010, 10:35 AM
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?
0
Iva Toteva
Telerik team
answered on 03 Jan 2011, 09:35 AM
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

0
uthaya
Top achievements
Rank 1
answered on 06 Jan 2011, 02:10 PM
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?
0
Mike
Telerik team
answered on 10 Jan 2011, 11:40 AM
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>>
0
uthaya
Top achievements
Rank 1
answered on 11 Jan 2011, 12:28 PM
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?
0
Iva Toteva
Telerik team
answered on 13 Jan 2011, 09:04 AM
Hi Uthaya,

 Printing the document in order to show it in a DataGrid is not a very good idea.

If you are not finding HtmlDataProvider and HtmlExportSettings, then you need to update to a newer version of the controls. You can download a free trial as I have explained in an earlier post, namely:

  • 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". 
  • Choose "Internal Builds Downloads" in the bottom right corner. On the new page, choose the related items from the two combo boxes and  download the hot fix.
Then, extract the files from the zip and replace the references in your project to match the new location where you have put the assemblies.
Let us know if you experience further difficulties.

Regards,
Iva
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Daní
Top achievements
Rank 1
answered on 17 Mar 2011, 06:21 PM
Hello,

After upgrading telerik dll's to Q1 2011setting default font size does not work as expected. I'm using a RadRichTextBox as following:
<telerik:RadRichTextBox x:Name="richTextBox" IsSelectionMiniToolBarEnabled="True" IsSpellCheckingEnabled="False"
                                    DocumentInheritsDefaultStyleSettings="True" FontFamily="Verdana" FontSize="12" Grid.Row="1">
                <telerik:RadRichTextBox.Resources>
                    <telerikXaml:XamlDataProvider x:Name="xamlDataProvider" RichTextBox="{Binding ElementName=richTextBox}" Xaml="{Binding Path=XamlText, Mode=TwoWay}" ccBehaviors:DefaultLineSpacingBehavior.DefaultLineSpacing="1"/>
                    <telerikTxt:TxtDataProvider x:Name="txtDataProvider" RichTextBox="{Binding ElementName=richTextBox}" Text="{Binding Path=PlainText, Mode=TwoWay}" ccBehaviors:DefaultLineSpacingBehavior.DefaultLineSpacing="1"/>
                </telerik:RadRichTextBox.Resources>
            </telerik:RadRichTextBox>

It was working fine with Q3 2010 version, RadRichTextBoxRibbonUI FontFamily was set to "Verdana" by default and RadRichTextBoxRibbonUI FontSize was set to "9" by default.But now the FontSize is set to "8.2" by default.
0
Daní
Top achievements
Rank 1
answered on 18 Mar 2011, 09:45 AM
Hello, 

It seems is a measurement unity issue. Setting FontSize property in Xaml in conjuntion with DocumentInheritsDefaultStylesSettings results in getting the default font size at "8.2" regardless the FontSetize value set. Fortunately I'm using a custom attached property for the DataProviders to set the default line spacing, in this "behavior" I can set the RichTextBox FontSize by code and then it works fine.
0
Iva Toteva
Telerik team
answered on 18 Mar 2011, 06:25 PM
Hello Daní,

We were not able to reproduce the issue on our side - neither with XamlDataProvider, nor with TxtDataProvider. Which one of the two providers are you using when observing the problem?
If it is Xaml, could you please verify that the font size is not specified in the document before the import? The default font values of the rich text box are only applied on spans/paragraphs that do not have explicit values set.
On a side note, 11 dip (~8.2 points)  is the default value of the font size of the UserControl, so if you do not set a value for the font size, it will inherit that one.
Could you please check once again if the behavior is not due to any of the above-listed reasons? If that is not the case, we would greatly appreciate a sample project to help us track down the causes.

Best wishes,
Iva
the Telerik team
0
Daní
Top achievements
Rank 1
answered on 21 Mar 2011, 10:14 AM
Hi Iva,

the issue is setting FontSize in xaml directly. It was working fine until I upgrade solution to Q1 2011 release. Since the upgrade, setting the FontSize, regardless the value provided, shows a "8.2" value in the ribbon's fontsise selector. The RichTextBox is inside a DataTemplate, and as I'm using a custom attached property to set the document's default line spacing I'm also setting the default size in this "behavior" and it works fine. Initially, RichTextBox is always empty, I'm using DataProviders to write a pair of my viewmodel properties.
0
Vesko
Telerik team
answered on 24 Mar 2011, 09:38 AM
Hi Daní,

Thanks for your question!
In this release we have slightly changed the behavior of the XamlFormatProvider. Now, when exporting RadDocument in XAML, all properties  such as FontFamily, FontSize, ForeColor, etc. are explicitly set no matter what is their value source - local or inherited. The reason to make this change is because we wanted to have the document looking exactly the same after export/import no matter what are the settings of the RadRichTextBox.

Probably that is the reason for your problem. You can check what is the XAML of the document set trough the XamlDataProvider and see whether these properties are explicitly set.

If this is the case and you need further assistance, please open a support ticket such that we to be able to try helping you further.

Kind regards,

Vesko
the Telerik team

 

0
Brian
Top achievements
Rank 1
answered on 30 Aug 2011, 09:13 PM
UPDATE:
I figured this out.  I was missing the following: DocumentInheritsDefaultStyleSettings="true"
-----------------------------------


I am trying to set the font size and family for my RichTextBox which uses a TxtDataProvider to receive it's data but I can't seem to get it to work.  No font changes are shown.  Here is my code:
<telerikFormatProvider:TxtDataProvider x:Name="txtDP" RichTextBox="{Binding ElementName=rtbPFConsult}" Text="{Binding Path=PFConsult, Mode=TwoWay}" MinHeight="100" />
<telerik:RadRichTextBox x:Name="rtbPFConsult" IsSpellCheckingEnabled="False" FontSize="14" FontFamily="Verdana" />

I have tried putting the TxtFormatProvider inside the RichTextBox Resources section but then nothing shows up at all.  Right now, I see my text but it is not formatted with my specified font size or family. 

How can I make this work?
0
uthaya
Top achievements
Rank 1
answered on 05 Nov 2011, 12:11 PM
Hello Sir,

Am Using Radrichtextbox inside my Datagrid, But I cannot able to bind the rad Document to that radrichtextbox. Code Snippet is given Bellow.

<sdk:DataGrid AutoGenerateColumns="False" Grid.Column="1"  Name="dataGrid1"  >
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" >
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadRichTextBox x:Name="richTextBox" Height="60">
                                <telerik:RadRichTextBox.Resources>
                                    <telerikXAML:XamlDataProvider x:Key="XamlDataProvider"  RichTextBox="{Binding ElementName=richTextBox}" Xaml="{Binding Data, Mode=TwoWay}"  />
                                </telerik:RadRichTextBox.Resources>
                            </telerik:RadRichTextBox>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>

In CodeBehind Code Snippet is given bellow

  private void BindData(string[] result)
        {        
            System.Collections.ObjectModel.ObservableCollection<clsMyData> objcoll = new System.Collections.ObjectModel.ObservableCollection<clsMyData>();
          
            foreach (string strData in result)
            {
                clsMyData obj = new clsMyData();
                obj.Data = ImportXaml(strData);
                objcoll.Add(obj);        
            }
            dataGrid1.ItemsSource = objcoll;
        }

        public RadDocument ImportXaml(string content)
        {
            XamlFormatProvider provider = new XamlFormatProvider();
            return provider.Import(content);
        }

        public string GetXamlFromDocument(RadDocument document)
        {
            IDocumentFormatProvider exporter = new XamlFormatProvider();
            string result = null;
            using (MemoryStream stream = new MemoryStream())
            {
                exporter.Export(document, stream);
                stream.Seek(0, SeekOrigin.Begin);
                StreamReader reader = new StreamReader(stream);
                result = reader.ReadToEnd();
            }
            return result;
        }

 public class clsMyData
    {
        RadDocument m_data;
        public RadDocument Data
        {
            get { return m_data; }
            set { m_data = value; }
        }
    }


By this Code, It Creates RadRichTextBox in Datagrid. but it shows blank. can please help me? awaiting for your reply.


0
Daní
Top achievements
Rank 1
answered on 05 Nov 2011, 03:28 PM
Hi uthaya,

Data property on class clsMyData should be string typed. You don't need to import your strings to RadDocument, this task is performed by XamlDataProvider. Xaml property in XamlDataProvider is string typed, so you need to bind it to an string value.
0
uthaya
Top achievements
Rank 1
answered on 07 Nov 2011, 06:37 AM
Hello,

Thank u for your response. Now the values are binded to the radrichtextbox in my datagrid, but if i bind 100 records to that datagrid, it creates 100 rows, but shows only 10 correct records, remaining 90 rows repeated the same 10 records 9 times. Can you please give me the solution. presently am using telerik trail controls, is trail control creates any problem? and also I need to print the datas which are shown in my datagrid, how to print the list of rad documents? please give your suggestion.
0
Daní
Top achievements
Rank 1
answered on 07 Nov 2011, 04:33 PM
Hi uthaya,

I think it may be a row virtualization issue. By default, RadGridView enables row virtualization. That means that it only creates as many rows as the view port contains (the number of rows visibles in your screen). As you scroll the radgridview it resuses the rows, updating its content to the new scolled content. RadRichTextBox is a heavy control, you need a XamlDataProvider to bind it,... may be row reutization do not perform quite well in this scenario.

Try to disable row virtualization, setting EnableRowVirtualization property on RadGridview control to false. That may solve your problem but create a new one: GridView performance!! In this scenario you may notice that scrolling is not smoothly at all. 

I'm using RichTextBox in an scenatio very similar. What I did is:
  1. Disabling row virtualization.
  2. Using a DataPager to minimize the number of rows to create. 

About printing, I posted a question some time ago in this forum. It may be useful for you.http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=378299

PS: Telerik trial version shouldn't be any issue. It the same as release versio but it adds some delay and an telerik's watermark.
0
uthaya
Top achievements
Rank 1
answered on 08 Nov 2011, 06:01 AM
Hi Dani,

Thanks for your suggestion. But I am using ordinary silverlight datagrid, In that data grid am using radrichtextbox. so can you please give some other solution.

For Printing, you already gave me a link, but its not your forum, its go for new support ticket creation page. so Please give me correct link.
Thanks in advance.
0
Iva Toteva
Telerik team
answered on 09 Nov 2011, 10:42 AM
Hello Uthaya,

It is possible that the context of the data providers is not updated properly because the data provider is declared in the resource dictionary of RadRichTextBox. As emphasized here, the data providers have to be in the visual tree in order to have their data context updated successfully.

As for printing, RadRichTextBox can only print/export one document. Therefore, the only solution would be to "merge" all documents into one, and print them. Here is how you can insert the content of one document into another:
documentToInsert.Selection.SelectAll();
DocumentFragment fragment = documentToInsert.Selection.CopySelectedDocumentElements();
this.radRichTextBox1.Document.InsertFragment(fragment);

Using this method, the fragment will be inserted in the other document at the current caret position (which by default is at the beginning of the document). Manipulating the caret position can be done as described in this article.

Regards,
Iva Toteva
the Telerik team

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

0
uthaya
Top achievements
Rank 1
answered on 09 Nov 2011, 12:11 PM
Hai Iva,

Thanks. Now XAML Binding problem solved.
0
Philipp
Top achievements
Rank 1
answered on 22 Mar 2012, 02:38 AM
Clearing values of Span element does not work. When you clear it - it retain the same value. Tested on WPF latest version of Telerik.
0
Boby
Telerik team
answered on 26 Mar 2012, 12:16 PM
Hi Philipp,
We were not able to reproduce the problem you described. Could you please elaborate more on how to repeat it, or open a support ticket and send us a sample project that reproduces it?

All the best,
Boby
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Philipp
Top achievements
Rank 1
answered on 28 Mar 2012, 01:30 AM
I have application which allows user to input formatted text and store in as HTML. It must have limitation of formatting capabilities provided to end-user - it should only support bold and italic with <b> and <i> tags. No styles, font names are allowed.

Here is the way to reproduce the issue:
Copy some formatted text from MS Word, paste it to Telerik Rich Text Box, then execute this code that removes formatting from span and other elements. When you try to convert it to HTML after that you still will see inline styles with font details in result HTML. This details will include styling of properties which you removed using you code.

Here is my XAML:
            <telerik:RadRichTextBox Grid.Row="1"
                                    IsContextMenuEnabled="True"
                                    IsSelectionMiniToolBarEnabled="False"
                                    IsSpellCheckingEnabled="False"
                                    Margin="8"
                                    Name="tbxIntroduction"
                                    AcceptsReturn="True"
                                    AcceptsTab="True"
                                    CommandExecuting="tbxIntroduction_CommandExecuting"
                                    DocumentInheritsDefaultStyleSettings="True"
                                    ShowFormattingSymbols="False"
                                    ShowMergeFieldsHighlight="True">
 
            </telerik:RadRichTextBox>
            <telerikHtml:HtmlDataProvider x:Name="htmlDataProvider"
                                          RichTextBox="{Binding ElementName=tbxIntroduction}"
                                          Html="{Binding Path=.,XamlExt.Path=(local:IInstructionsEditorModel.Introduction), Mode=TwoWay, Converter={x:Static local:IntroductionHtmlConverter.Global}}">
                <telerikHtml:HtmlDataProvider.FormatProvider>
                    <telerikHtml:HtmlFormatProvider>
                        <telerikHtml:HtmlFormatProvider.ImportSettings>
                            <telerikDocumentsHtml:HtmlImportSettings  UseDefaultStylesheetForFontProperties="True" />
                        </telerikHtml:HtmlFormatProvider.ImportSettings>
                        <telerikHtml:HtmlFormatProvider.ExportSettings>
                            <telerikDocumentsHtml:HtmlExportSettings DocumentExportLevel="Fragment"
                                                                     ExportFontStylesAsTags="True"
                                                                     ExportStyleMetadata="False"
                                                                     ImageExportMode="None"
                                                                     StyleRepositoryExportMode="ExportStylesAsCssClasses"
                                                                     StylesExportMode="Inline" />
                        </telerikHtml:HtmlFormatProvider.ExportSettings>
                    </telerikHtml:HtmlFormatProvider>
                </telerikHtml:HtmlDataProvider.FormatProvider>
0
Iva Toteva
Telerik team
answered on 30 Mar 2012, 04:08 PM
Hi Phillip,

The methods that clear the values of a span's FontFamily, FontSize, FontWeight, etc. do remove the values of these properties of the Span. Therefore, the spans will be shown with the default font settings of RadRichTextBox - Verdana 12 pt (unless something else is specified in the properties of RadRichTextBox or its containers in the visual tree and DocumentInheritsDefaultStyleSettings="True").

When it comes to the export to HTML, HtmlFormatProvider exports the values of the font family and font size, in order to ensure the same look of the document when it is previewed in a browser or another consumer of the HTML.

What you can do with the current version of the control is to set-up the rich text box like this:

<telerik:RadRichTextBox Grid.Row="2"
            IsContextMenuEnabled="True"
            IsSelectionMiniToolBarEnabled="False"
            IsSpellCheckingEnabled="False"
            Name="tbxIntroduction"
            AcceptsReturn="True"
            AcceptsTab="True"
            CommandExecuting="tbxIntroduction_CommandExecuting"
            ShowFormattingSymbols="False"
            ShowMergeFieldsHighlight="True">
</telerik:RadRichTextBox>
<telerikHtml:HtmlDataProvider x:Name="htmlDataProvider"
                                  RichTextBox="{Binding ElementName=tbxIntroduction}"
                                  Html="{Binding Path=.,XamlExt.Path=(local:IInstructionsEditorModel.Introduction), Mode=TwoWay, Converter={x:Static local:IntroductionHtmlConverter.Global}}">
    <telerikHtml:HtmlDataProvider.FormatProvider>
        <telerikHtml:HtmlFormatProvider>
            <telerikHtml:HtmlFormatProvider.ImportSettings>
                <telerikDocumentsHtml:HtmlImportSettings  UseDefaultStylesheetForFontProperties="True" />
            </telerikHtml:HtmlFormatProvider.ImportSettings>
            <telerikHtml:HtmlFormatProvider.ExportSettings>
                <telerikDocumentsHtml:HtmlExportSettings DocumentExportLevel="Fragment"
                      ImageExportMode="None"
                      ExportFontStylesAsTags="True"
                      ExportStyleMetadata="False"
                      StyleRepositoryExportMode="ExportStylesAsCssClasses"
                      StylesExportMode="Inline"
                   />
            </telerikHtml:HtmlFormatProvider.ExportSettings>
        </telerikHtml:HtmlFormatProvider>
    </telerikHtml:HtmlDataProvider.FormatProvider>
</telerikHtml:HtmlDataProvider>


And in the CommandExecuting handler clear the values you wish to ignore:
private void tbxIntroduction_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
    if (e.Command is PasteCommand)
    {
        DocumentFragment fragment = ClipboardEx.GetDocument();
        foreach (Span span in fragment.EnumerateChildrenOfType<Span>())
        {
            span.ClearValue(Span.FontSizeProperty);
            span.ClearValue(Span.FontFamilyProperty);
            span.ClearValue(Span.ForeColorProperty);
        }
        ClipboardEx.SetDocument(fragment);
    }
}

I hope this solution suits your requirements.
All the best,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Amruta
Top achievements
Rank 1
answered on 02 Apr 2015, 09:33 AM
Hi

I used your code to change font from xaml by setting properties like font family and font size.
Then I add some line in textbox and saved. Again when i open textbox I was expecting setting will retain, but again default font verdana was set.
see html generated using Arial font as default :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled</title><style type="text/css">
p { text-indent: 0pt;padding: 0px 0px 0px 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 12px;margin-left: 0px;text-align: left;font-family: 'Verdana';font-style: Normal;font-weight: normal;font-size: 16px;color: #000000; } 
.defaultDocumentStyle { telerik-style-type: default;telerik-style-name: defaultDocumentStyle;font-family: 'Arial';font-style: Normal;font-weight: normal;font-size: 14px;margin-bottom: 12px; } 
.p_E2968D9D { telerik-style-type: local; } 
.s_E2968D9D { telerik-style-type: local; } 
</style></head><body><p class="p_E2968D9D"><span class="s_E2968D9D">TEST</span></p></body></html>





















0
Petya
Telerik team
answered on 06 Apr 2015, 03:25 PM
Hi Amruta,

I'm not sure what version of the control you are using, but could not reproduce the behavior you are seeing. Are you setting additional properties to the control or maybe specifying export settings for the HtmlFormatProvider?

I'd suggest upgrading the version of Telerik UI for Silverlight that you are using to the most recent one to take advantage of all new features and fixes we've implemented.

Regards,
Petya
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Amruta
Top achievements
Rank 1
answered on 07 Apr 2015, 06:44 AM

Hi

 

I am using Telerik.Windows.Controls 2011.3.1220.1050 .

Also no export settings for HtmlDataProvider set. Please suggest a way to fix this issue?

 

Tags
RichTextBox
Asked by
David
Top achievements
Rank 1
Answers by
Boby
Telerik team
Chen
Top achievements
Rank 1
namratha
Top achievements
Rank 2
Iva Toteva
Telerik team
Michael Montgomery
Top achievements
Rank 1
Daní
Top achievements
Rank 1
Kirk Quinbar
Top achievements
Rank 1
uthaya
Top achievements
Rank 1
Donna
Telerik team
Mike
Telerik team
Vesko
Telerik team
Brian
Top achievements
Rank 1
Philipp
Top achievements
Rank 1
Amruta
Top achievements
Rank 1
Petya
Telerik team
Share this question
or