Completed
Last Updated: 25 Jun 2016 13:17 by ADMIN
ADMIN
Todor
Created on: 25 Feb 2016 09:40
Category: RichTextBox
Type: Bug Report
1
Pasting text containing a field with style in its code fragment causes an exception if the document is bound through a RtfDataProvider
Workaround: Manipulate the clipboard content in CommandExecuting even handler:

private void RichTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
    if (e.Command is PasteCommand)
    {
        DocumentFragment document = ClipboardEx.GetDocument();
        bool hasChangedDocument = false;

        foreach (FieldRangeStart fieldStart in document.EnumerateChildrenOfType<FieldRangeStart>())
        {
            foreach (Span span in fieldStart.Field.GetFragmentByDisplayMode(FieldDisplayMode.Code).EnumerateChildrenOfType<Span>())
            {
                span.ForeColor = Colors.Black;
                hasChangedDocument = true;
            }
        }

        if (hasChangedDocument)
        {
            ClipboardEx.SetDocument(document);
        }
    }
}
1 comment
ADMIN
Aylin
Posted on: 25 Jun 2016 13:17
Hi,

The issue is fixed and will be included in our next LIB release.
Do not hesitate to contact us if any issues or questions arise.

Regards,
The Telerik Team