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 3623488
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:23:22+00:00 2026-05-18T23:23:22+00:00

We’re currently using WPF to create a multi-page invoice document, to then be printed

  • 0

We’re currently using WPF to create a multi-page invoice document, to then be printed / exported via XPS.

The route we’ve taken to achieve this is to create a UserControl containing a standard ListBox etc displaying the Invoice lines, this is then included in a FlowDocument inside BlockUIContainer tags.

When this FlowDocument is placed inside FlowDocumentScrollViewer tags in a window, it works perfectly, with the databound content of the UserControl displaying properly. However, when we try to create the same FlowDocument in code, it fails with a “‘Cannot create unknown type ‘{clr-namespace:FOO}FooUserControl” XamlParseException. The FlowDocument can be successfully created programmatically if the UserControl is removed.

This is the FlowDocument XAML:

<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:local="clr-namespace:MARS"
          ColumnWidth="400" FontSize="14" FontFamily="Georgia">
<Paragraph>
    Blah
</Paragraph>

<BlockUIContainer>
    <local:printTestUserControl></local:printTestUserControl>
</BlockUIContainer>

And this is the code we are using to create it in code:

FileStream xamlFile = new FileStream("printTestFlowDoc.xaml", FileMode.Open, FileAccess.Read);            
FlowDocument content = (FlowDocument)XamlReader.Load(xamlFile);
flowDocScrollViewer.Document = content;
xamlFile.Close();

The reason we’re creating the FlowDocument in code is to then use a Paginator object to slice it into a series of FixedDocuments to then print / export to XPS, none of which we’ve yet tried, but from what i’ve read so far it seems like this is a feasible method of achieving multi-page document printing in WPF (Where the document will have a header on the first page, a totals footer on the last, and x pages of rows in between).

Any advice on this issue, or other methods of doing this would be very welcome.

These are some links we’ve picked up bits of information from so far, sadly not enough though! (I’ll include the other links in comments, as StackOverflow doesn’t trust me with more than one link at present!)

See the section “Dynamically Creating a FlowDocument, Data Binding and Printing It” Scott Hanselmann seemed to have the same problem as we did, but adding the line

Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.SystemIdle, new DispatcherOperationCallback(delegate { return null; }), null);

didn’t get our FlowDocument to load, however he was only binding to TextBlocks in his FlowDocument, rather than including a UserControl.

Thanks very much for reading this far! and for any help anyone can offer.

  • 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-18T23:23:23+00:00Added an answer on May 18, 2026 at 11:23 pm

    Sorry i’ve been so slow in tidying up this question, but we’ve just finished this project, and i’m now tidying up all the loose ends from it.

    It turned out that the flowdocument / XPS method was a completely wrong headed way of approaching this task, and in fact the built in RDLC reports allowed us to achieve everything we needed for our invoice documents, in a relatively straight forward manner.

    The main bonus of this was that we were able to report on in-memory instances of our business model objects, rather than having to use data looked up from a db, via stored procs called from crystal, which the previous system relied upon. The report file editor in VS was simple to get to grips with, if at times a little irritating when laying out complex reports.

    Hopefully this may be of some use to people considering their options when it comes to reporting from WPF applications.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

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.