Working with PasteOptionsPopup may cause an exception in LayoutElement.SetParent. Very difficult to reproduce, having no consistent steps. Maybe it is related to undo of paste command, but there are no other clues aside from this.
bei Telerik.Windows.Documents.Layout.LayoutElement.SetParent(LayoutElement newParent)In this feature, the existing text is overridden as the user types on it with the "Insert" key is pressed on the keyboard.
Workaround: Track the state of the Insert key and delete before inserting content using the KeyDown and CommandExecuting events:
private void MainDemoControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.KeyboardDevice.IsKeyToggled(Key.Insert))
{
this.isInsertKeyPressed = true;
}
else
{
this.isInsertKeyPressed = false;
}
}
private void radRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is InsertTextCommand && this.isInsertKeyPressed)
{
this.radRichTextBox.Delete(false);
}
}