Creating deep copy using CreateDeepCopy method of an empty Section (without paragraphs or with one empty paragraph) adds empty string Span which leads to ArgumentOutOfRangeException.
Workaround: clear the empty string Spans before measuring:
foreach (Span span in sectionClone.EnumerateChildrenOfType<Span>().ToList())
{
if (string.IsNullOrEmpty(span.Text))
{
((Paragraph)span.Parent).Inlines.Remove(span);
}
}
Steps to reproduce:
1. Execute the following code-snippet:
RadDocument document = new RadDocument();
Section section = new Section();
section.Blocks.Add(new Paragraph());
document.Sections.Add(section);
RadDocument documentClone = (RadDocument)document.CreateDeepCopy();
Section sectionClone = (Section)section.CreateDeepCopy();
documentClone.Sections.Clear();
documentClone.Sections.Add(sectionClone);
documentClone.EnsureDocumentMeasuredAndArranged();
2. Set the documentClone to a RadRichTextBox instance to visualize it.
3. Try to click in the document.
Observe: ArgumentOutOfRangeException is thrown.