The start and end annotations are pasted along with the other content, trying to update the styles leads to cycle and StackOverflowException is thrown.
Workaround: Remove the comments from the document in the clipboard:
void radRichTextBox_ActiveDocumentEditorChanged(object sender, Telerik.Windows.Documents.UI.ActiveDocumentEditorChangedEventArgs e)
{
if (e.DocumentEditorType == Telerik.Windows.Documents.UI.DocumentEditorType.Comment)
{
var currentEditor = this.radRichTextBox.ActiveDocumentEditor as RadRichTextBox;
currentEditor.CommandExecuting += activeEditor_CommandExecuting;
}
}
void activeEditor_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is PasteCommand)
{
RadDocument pastedDocument = ClipboardEx.GetDocument().ToDocument();
RadDocumentEditor editor = new RadDocumentEditor(pastedDocument);
editor.DeleteAllComments();
ClipboardEx.SetDocument(new DocumentFragment(pastedDocument));
}
}