RadRichTextBox is not allowing copy pasting from different document and also from another RadRichTextBox.
If I am copying from same RadRichTextBox and then pasting it to same RadRichTextBox, then it is working fine.
So, I took reference from below doc:
WPF RichTextBox - Clipboard Support - Telerik UI for WPF
and implemented below function:
private void RadRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is PasteCommand)
{
e.Cancel = true;
// Obtain the document inside the clipboard
RadDocument document = ClipboardEx.GetDocument().ToDocument();
// Change it according to your needs
document.Selection.SelectAll();
RadDocumentEditor editor = new RadDocumentEditor(document);
editor.ChangeFontSize(Unit.PointToDip(12));
// Insert it in RadRichTextBox
this.radRichTextBox.InsertFragment(new DocumentFragment(document));
}
}
I observed that if I am copying from another doc and pasting to that RadRichTextBox then
RadDocument document = ClipboardEx.GetDocument().ToDocument();
this line is giving System.NullReferenceException: 'Object reference not set to an instance of an object.'
How to fix this?
Paste plain text when copying\pasting in same RadRichTextBox in UI for WPF | Telerik Forums