I tested this case and was unable to reproduce a StackOverflowException. However, I observe some inconsistent behavior on our end when more than one tagged element is present in the document.
When you add the elements in your breaks
collection all positions are as should be. However, once you perform the first insertion of a section break, all sequential positions point to the wrong place, which is expected.
Also, though the method you choose for inserting a section break works, the Undo command cannot be used to reverse each inserted break. In order to preserve the history, you should use a method of the editor instead.
I have modified the above code to use the editor method and avoided traversing the layout boxes of the document in the process as that too may cause issues. In addition, I was able to implement the method with one foreach
cycle, so it should also perform better.
RadDocument MyRadDocument =
var documentElements = MyRadDocument.EnumerateChildrenOfType<Paragraph>();
var taggedElements = documentElements.Where(e => e.Tag ==
I hope this will be helpful. Let us know how it goes and if you are still experiencing issues get back to us with additional details (stack
All the best,