Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 484435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:17:57+00:00 2026-05-13T01:17:57+00:00

How can i copy the contents of one FlowDocument to another FlowDocument below is

  • 0

How can i copy the contents of one FlowDocument to another FlowDocument below is what i tryed

foreach (var blk in fd1.Blocks)
{
   fd2.Blocks.Add(blk);
}

fd1 is FlowDocument1 and fd2 is FlowDocument2.

But i get the below error.

Collection was modified; enumeration operation may not execute.

Thanks

Arvind

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:17:58+00:00Added an answer on May 13, 2026 at 1:17 am

    Because each Block is ‘owned’ by a FlowDocument, it cannot just be added to another. You must serialize it and then deserialize it, which breaks the bond with the original FlowDocument, which allows you to add it to another.

    /// <summary>
    /// Adds one flowdocument to another.
    /// </summary>
    /// <param name="from">From.</param>
    /// <param name="to">To.</param>
    public static void AddDocument(FlowDocument from, FlowDocument to)
    {
        TextRange range = new TextRange(from.ContentStart, from.ContentEnd);
        MemoryStream stream = new MemoryStream();
        System.Windows.Markup.XamlWriter.Save(range, stream);
        range.Save(stream, DataFormats.XamlPackage);
        TextRange range2 = new TextRange(to.ContentEnd, to.ContentEnd);
        range2.Load(stream, DataFormats.XamlPackage);
    }
    

    This was copied from:

    http://social.msdn.microsoft.com/Forums/en/wpf/thread/f4b26d9b-5b74-446b-85e7-e49e519380ad

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to copy contents of one xml file into another xml file.
I want to copy the entire contents of a directory from one location to
I have a Subversion working copy with at least one missing file (the local
With Silverlight 4, I can select one or more cells (or rows and columns)
I am testing one application that handles files (stored in SQL Server using FILESTREAM
I have a file on my computer that I wanted to copy into a
I have two Word documents (WordprocessingDocument), and I want to replace the contents of
If I understand correctly, a broswer caches images, JS files, etc. based on the
I have a project that consists of a bunch of dynamically loaded modules. Originally,
Please have a look to the following code: <?php $nomeDominio=''; if (isset($_GET['infoDominio'])) { $nomeDominio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.