Insert New Paragraph in Caret Position

2 posts, 0 answers
  1. Ozan Bora
    Ozan Bora avatar
    1 posts
    Member since:
    Jul 2012

    Posted 05 Jul 2012 Link to this post

    Hi,

    I'm trying to insert a paragraph, which I want it to have a numbered item as well, to the caret position using Q3 2011 SP1. 
    DocumentFragment is the only workaround that I found for the paragraph issue. But when I have numbered list in my document fragment it will be a different Document List as soon as I insert fragment to document. Consider the following example

    originalParagraph.Inlines.Add(new Span("Numbered Item in Original Document"));
                originalNumberedList.AddParagraph(originalParagraph);
     
                originalSection.Blocks.Add(originalParagraph);
                originalSection.Blocks.Add(new Paragraph());
                originalDocument.Sections.Add(originalSection);
                originalDocument.CaretPosition.MoveToLastPositionInDocument();
     
                RadDocument documentFragment = new RadDocument();
                Section sectionFragment = new Section();
     
                NumberedList numberedListForFragment = new NumberedList(documentFragment);
                Paragraph paragraphFragment = new Paragraph();
     
                paragraphFragment.Inlines.Add(new Span("Numbered Item in Document Fragment"));
                numberedListForFragment.AddParagraph(paragraphFragment);
     
                sectionFragment.Blocks.Add(paragraphFragment);
                documentFragment.Sections.Add(sectionFragment);
     
                originalDocument.InsertFragment(new DocumentFragment(documentFragment));

    If I use the same NumberedList defined for original document, Numbered List in original document is updated.

    RadDocument originalDocument = new RadDocument();
                Section originalSection = new Section();
     
                NumberedList originalNumberedList = new NumberedList(originalDocument);
                Paragraph originalParagraph = new Paragraph();
     
                originalParagraph.Inlines.Add(new Span("Numbered Item in Original Document"));
                originalNumberedList.AddParagraph(originalParagraph);
     
                originalSection.Blocks.Add(originalParagraph);
                originalSection.Blocks.Add(new Paragraph());
                originalDocument.Sections.Add(originalSection);
                originalDocument.CaretPosition.MoveToLastPositionInDocument();
     
                RadDocument documentFragment = new RadDocument();
                Section sectionFragment = new Section();
     
                Paragraph paragraphFragment = new Paragraph();
     
                paragraphFragment.Inlines.Add(new Span("Numbered Item in Document Fragment"));
                originalNumberedList.AddParagraph(paragraphFragment);
     
                sectionFragment.Blocks.Add(paragraphFragment);
                documentFragment.Sections.Add(sectionFragment);
     
                originalDocument.InsertFragment(new DocumentFragment(documentFragment));

    The thing is if I export and import the document using XamlFormatProvider the problem seems to be resolved. Is there any other workaround for this issue?

  2. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 10 Jul 2012 Link to this post

    Hi Ozan,

    Using both approaches you described when the fragment is inserted, two paragraphs are created that are part of the same list (numbered 1 and 2). You can see the screenshot attached. If that is not what you expect, please elaborate a little bit more on what your expected result is (and send screenshot if possible).

    All the best,
    Andrew
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top