4

I have coded up a ListView report using xaml, mvvm and it works just fine. The xaml code deploys ListView.GroupStyle and the resulting report has a group header, items listing and group totals and counts.
It looks like this: enter image description here

I would like to print this same report to the printer. It is multipage and the groups alone could span more than a page, depending on the reporting date span. I would also want to show the column headers at the top of each printed page.

I have read (and practiced) printing ListView reports before to a FixedPage / Fixed Document and calculating the item source for each page to spread the printed report over multiple pages.

This time because I am using the groupings, the problems appear more difficult? I cannot see how to calculate the item source for each page. I’m thinking I need to somehow construct the report as a single unbound (no page size restriction) ListView, pluck out the ListViewItems and then use those items to construct my report.

I have read solutions using FlowDocument, but do not see an answer there?

Can anyone give me some ideas how to solve this problem?

Community
  • 1
  • 1
Allan
  • 449
  • 5
  • 11

1 Answers1

2

Here is advice in the acepted answer to StackOverflow link you quoted:

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.

This is the route I would take.

Here is a link to a CodeProject article which prints a datagrid with repeating headers, pretty much what you are asking, if you still want to continue with your oirignal approach:

CodeProject - Custom Data Grid Document Paginator

And there are several good answers with other approaches in this StackOverflow question -

StackOverflow - Whats the best approach to printing reporting from wpf

Community
  • 1
  • 1
Edward
  • 8,028
  • 2
  • 36
  • 43