For instance I have to cut fragment from a document and paste it in another one. The fragment is AnnotationRange and it has others annotation elements inside. When I insert it GetRootDocument for parent element is not null (it's my document), but for children it is null.
How can I set my document as owner for all internal elements?
Thanks in advance.
5 Answers, 1 is accepted
If you are enumerating the elements in the document fragment which shall be pasted into another document, their root document is normal to be null, because the root document calculations are based on the document collection elements and the corresponding to the elements associated layout boxes.
However, after the insertion of the fragment in the new document, the root document of the inserted DocumentElement objects should be the document where they are inserted to. There isn't a way to change the document owner of a document element and this is by design.
I hope this information is helpful.
Todor, thank you for your anwer.
The elements from the document fragment are not displayed after inserting the fragment in my document. How can I use these elements from editor if editor's document isn't owner of them?
I'm not sure I understand your exact scenario. Please try to shed some more light on what you are trying to achieve and what the desired result should be. Maybe we can suggest you a more suitable solution for the problem.
About the not displayed document elements after insertion of a document fragment - I've tried to reproduce the issue, but to no avail. You can find the project with which I've tested attached. Please, try to modify it or create another one and send it back to us. In this way, it will be much easier for us to find what might cause the issue.
Looking forward to your reply.
Todor, thank you.
I've changed your solution.Sorry, if my variant is large or complex.
I marked with breakpoint where it was problem with root document.
P.S. I renamed .zip to .jpg because .zip is from not allowed type.
I've tested the project you've sent and the annotations are inserted. You can easily verify that by just enumerating the inlines of the Document of the second RadRichTextBox (the one with "rtb2").
However, the text representation depends on the implementation of your custom document elements. In your case, the Souce property of your FieldStart object holds the text which is copied from the first Document. You should modify the DataRangeStart.CreateDocumentFragment() method (and more precisely the GetDocumentFragment() implementation in the classes which inherit the DataRangeStart class) which is invoked from the DrawContent() method in order the correct Span or other elements to be inserted in the DocumentFragment.
More about Annotations and custom Annotations you can read in the corresponding help articles.