Inserting annotation in document

6 posts, 0 answers
  1. Alexander
    Alexander avatar
    20 posts
    Member since:
    Aug 2014

    Posted 06 Dec 2015 Link to this post

    Hi,

    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.

  2. Todor
    Admin
    Todor avatar
    168 posts

    Posted 09 Dec 2015 Link to this post

    Hi Alexander,

    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.

    Regards,
    Todor
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alexander
    Alexander avatar
    20 posts
    Member since:
    Aug 2014

    Posted 09 Dec 2015 in reply to Todor Link to this post

    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?

  5. Todor
    Admin
    Todor avatar
    168 posts

    Posted 12 Dec 2015 Link to this post

    Hello Alexander,

    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.

    Regards,
    Todor
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Alexander
    Alexander avatar
    20 posts
    Member since:
    Aug 2014

    Posted 13 Dec 2015 in reply to Todor Link to this post

    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.

  7. Todor
    Admin
    Todor avatar
    168 posts

    Posted 16 Dec 2015 Link to this post

    Hello Alexander,

    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 x:Name "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.

    Regards,
    Todor
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready