This question is locked. New answers and comments are not allowed.
Hello,
I'm using the RadRichTextBox throughout the application I'm developing. But I noticed something strange. When I run the application and insert a table in a RadRichTextBox under one or more lines of text, then the text is stretched (more space between lines and between words.)
I'm using a TableSizePicker for inserting tables in the RadRichTextBox, like in the following code snippet. The TableSizePicker has a binding with the InsertTableCommand of the RadRichTextBox.
<telerik:RadRibbonDropDownButton x:Name="btnTable" DataContext="{Binding Commands, ElementName=richTextEditor}" Command="{Binding Path=InsertTableCommand}" Style="{StaticResource ToolbarInsertTableDropDownButtonStyle}"> <Image Source="..." Style="{StaticResource ToolbarButtonImageStyle}" ToolTipService.ToolTip="..."/> <telerik:RadRibbonDropDownButton.DropDownContent> <telerik:RadRibbonButton ClickMode="Press"> <telerik:TableSizePicker DataContext="{Binding Commands, ElementName=richTextEditor}" Command="{Binding Path=InsertTableCommand}" /> </telerik:RadRibbonButton> </telerik:RadRibbonDropDownButton.DropDownContent> </telerik:RadRibbonDropDownButton>The xaml code of the RadRichTextBox looks like this:
<telerikDocuments:RadRichTextBox x:Name="richTextEditor" Background="{x:Null}" BorderBrush="{x:Null}" MinWidth="840" MaxWidth="920" FontFamily="Arial" FontSize="11" HorizontalAlignment="Left" LostFocus="richTextEditor_LostFocus" Loaded="richTextEditor_Loaded" DocumentChanged="richTextEditor_DocumentChanged" DocumentChanging="richTextEditor_DocumentChanging"> <telerikDocuments:RadRichTextBox.Document> <telerikDocumentsModel:RadDocument x:Name="rteDocument" LayoutMode="Flow" SectionDefaultPageMargin="3, 3, 3, 3" PageViewMargin="3, 3" ParagraphDefaultSpacingAfter="10" ParagraphDefaultSpacingBefore="0"> </telerikDocumentsModel:RadDocument> </telerikDocuments:RadRichTextBox.Document> </telerikDocuments:RadRichTextBox>I think that the issue is related to the code I use the set the default font and font size of a table when that table is inserted in the RadRichTextBox. Because the issue does not seem to occur when I remove this code:
private void richTextEditor_DocumentChanged(object sender, EventArgs e) { if (this.richTextEditor != null && this.richTextEditor.Document != null) { this.richTextEditor.Document.DocumentElementAdded += Document_DocumentElementAdded; } } private void richTextEditor_DocumentChanging(object sender, EventArgs e) { if (this.richTextEditor != null && this.richTextEditor.Document != null) { this.richTextEditor.Document.DocumentElementAdded -= Document_DocumentElementAdded; } } private void Document_DocumentElementAdded(object sender, Telerik.Windows.Documents.Model.DocumentElementAddedEventArgs e) { if (e.DocumentElement is Table) { string font = "Arial"; if (cmbFonts.SelectedItem != null) font = ((RadComboBoxItem)cmbFonts.SelectedItem).Content.ToString(); e.DocumentElement.DefaultStyleSettings.SetPropertyValue(Span.FontFamilyProperty, new FontFamily(font)); string fontSize = "11"; if (cmbFontSizes.SelectedItem != null) fontSize = ((RadComboBoxItem)cmbFontSizes.SelectedItem).Content.ToString(); e.DocumentElement.DefaultStyleSettings.SetPropertyValue(Paragraph.FontSizeProperty, fontSize); e.DocumentElement.DefaultStyleSettings.SetPropertyValue(Span.FontSizeProperty, fontSize); } }Any ideas?
Thanks
Sodi