The scenario:
We have a document with text inside and we are executing the following steps:
Observed: Before releasing the mouse button the cursor position is correct but after releasing it the cursor position is changed to the initial selection end.
A user reported a significant performance impact with the RichTextBox in our recent update. The UI hangs repeatedly while typing.
Profiling showed a lot of garbage collections, and profiling highlighted the the Telerik class Telerik.Windows.Controls.MarkupExtensions.DocumentsResourceProvider.
#if NETCORE
private static Style ThemeStyle
{
get
{
if (themeStyle == null)
{
themeStyle = GetStyleFromApplicationTheme();
}
return themeStyle;
}
}
private static Style GetStyleFromApplicationTheme()
{
if (StyleManager.IsEnabled && StyleManager.ApplicationTheme != null)
{
var themeName = StyleManager.ApplicationTheme.GetType().Name.Trim('_').ToLower();
themeName = themeName.Replace("theme", string.Empty);
var themesGeneric = Application.LoadComponent(new Uri("/Telerik.Windows.Controls.RichTextBox;component/themes/generic.xaml", UriKind.Relative)) as ResourceDictionary;
if (themesGeneric != null)
{
var currentThemeDictionary = themesGeneric.MergedDictionaries.FirstOrDefault(rd => rd.Source != null && rd.Source.OriginalString.ToLower().Contains(themeName));
if (currentThemeDictionary != null)
{
return currentThemeDictionary[typeof(DocumentsResourceProvider)] as Style;
}
}
}
return null;
}
I copied this code into my project to debug it, and found:
As the method returns null, it means themeStyle is always null, and it will try again on the next caller. This code is called repeatedly while typing. Using my code (and reflection) to force this ThemeStyle to Fluent fixes the performance, though obviously is a huge workaround.
DeleteAnnotationRange fails to execute when the content is uneditable annotation. For example: PermissionRange with a checkbox content control inside.
A possible workaround would be to manually delete the annotation range from the document element tree:
var rangeEnd = rangeStart.End;
var endParent = rangeEnd.Parent;
if (endParent != null)
{
endParent.Children.Remove(rangeEnd);
}
var parent = rangeStart.Parent;
if (parent != null)
{
parent.Children.Remove(rangeStart);
}
this.radRichTextBox.UpdateEditorLayout();
The AddParagraphToSelection method adds the first row of a table when it is the element after the paragraph.
To workaround this manually select the paragraph:
var para = caret.GetCurrentParagraph(); DocumentPosition pos = new DocumentPosition(doc); pos.MoveToDocumentElementStart(para); selection.AddSelectionStart(pos); pos.MoveToDocumentElementEnd(para); selection.AddSelectionEnd(pos); this.radRichTextBox.Delete(false);
1 Open RadRichTextBox and press Windows + . to to show the emoji box.
2 Choose the emoji and press backspace to remove it.
Actual behavior: When you press the backspace to remove the emoji, a square is left
Expected behavior: When you press the backspace the emoji should be deleted.
The issue is observed when the added table is preceded by a paragraph with a font size different from the default one. As the issue is caused by a broken mouse capture, the following workaround can be employed:
someRandomFrameworkElement.CaptureMouse();
someRandomFrameworkElement.ReleaseMouseCapture();
When a whole paragraph is selected and the Set Numbering Value command is executed, the numbering value of the next paragraph is changed instead of the current one.
Workaround: Clear the selection prior to executing the command:private void radRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is ShowSetNumberingValueDialogCommand)
{
this.radRichTextBox.Document.CaretPosition.MoveToPosition(this.radRichTextBox.Document.Selection.Ranges.First.StartPosition);
}
}
Using the microsoft word,In docx document,inserting a shape,and add the text context to the shape,then save.
when radrichtextbox open the file,the program crashed.
Exception when importing a document with an empty table.
Workaround: Remove the empty tables:
DocxFormatProvider provider = new DocxFormatProvider();
var doc = provider.Import(File.ReadAllBytes(@"C:\Users\mpc\Downloads\22-51.docx"));
foreach (var section in doc.Sections)
{
var tables = section.EnumerateChildrenOfType<Table>();
foreach (var table in tables.ToList())
{
if (table.Rows.Count == 0)
{
section.Blocks.Remove(table);
}
}
}
radRichTextBox.Document = doc;