I have no idea how to reproduce this, but every so often after a paste operation into a RadRichTextBox, the host thread becomes unresponsive to user input. The message pump is still running but the following unhandled exception gets thrown in a tight infinite loop. The only way to close the window is to right click on the taskbar button.
System.NullReferenceException
Message: Object reference not set to an instance of an object.
Call Stack:
at Telerik.Windows.Documents.Layout.LayoutElement.SetParent(LayoutElement newParent)
at Telerik.Windows.Documents.Layout.LayoutBox.EnsureParent()
at Telerik.Windows.Documents.Layout.LayoutBox.get_Parent()
at Telerik.Windows.Documents.Layout.FormattingSymbolLayoutBox.get_IsEndOfCell()
at Telerik.Windows.Documents.Layout.FormattingSymbolLayoutBox.GetFormattingSymbolVisual()
at Telerik.Windows.Documents.SpanBoxPositionHandler.get_Location()
at Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.GetViewPointFromDocumentPosition(DocumentPosition position)
at Telerik.Windows.Controls.RichTextBoxUI.PasteOptionsPopup.CalculateLocation()
at Telerik.Windows.Controls.RichTextBoxUI.PasteOptionsPopup.OnOwnerLayoutUpdated(Object sender, EventArgs e)
at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Scenario 1:
The <br/> tags after </li> are treated as separate paragraphs and inherit the list styling of the previous paragraphs resulting in duplicate bullets.
Workaround:
var paragraphsToRemove = this.radRichTextBox.Document.EnumerateChildrenOfType<Paragraph>().Where(p => p.IsInList && p.Inlines.First() is Break);
foreach (var p in paragraphsToRemove)
{
p.ListId = -1;
}
this.radRichTextBox.UpdateEditorLayout();
Scenario 2:
The <br/> tags added as the last element of <li> are treated as break elements in the content, causing additional new lines in the document.
Workaround:
var paragraphsWithLineBreak = document.EnumerateChildrenOfType<Paragraph>().Where(p => p.IsInList && p.Inlines.Last() is Break);
foreach (var p in paragraphsWithLineBreak)
{
p.Inlines.Remove(p.Inlines.Last);
}
this.richtextbox.Document = document;
a:hover { color: #3ca9f6 }
Paste some text inside RadRichTextEditor. If the text has more rows than the currently visible area you will see that the control does not scroll down to the caret position.
Workaround:
private void RadRichTextBox_CommandExecuted(object sender, CommandExecutedEventArgs e)
{
if (e.Command is PasteCommand)
{
Application.DoEvents();
bool cursorAtDocEnd = this.radRichTextBox.Document.CaretPosition.IsPositionAtDocumentEnd;
if (cursorAtDocEnd)
{
MoveCaretCommand command = new MoveCaretCommand(this.radRichTextBox.RichTextBoxElement);
command.Execute(MoveCaretDirections.Down);
}
}
}
Dear all,
Exporting partially-selected annotation ranges (annotation markers around selection or only one annotation marker in the selection) with a DocumentFragment from a RadDocument does not seem possible (the DocumentFragment contains none of these annotation ranges).
For example, if I have a document ("[", "]" are the annotation markers):
"Test [annotated]",
select "Test [ann" and create a DocumentFragment, the Document fragment will contain "Test ann" and not "Test [ann]".
PS.: I am not sure if this falls into the feature request or bug report area.
<!DOCTYPE html>
<html>
<body>
<div><p>RadDocument</p></div>
<div>Document</div>
</body>
</html>