简体   繁体   English

使用GroupStyle时WPF多页Listview打印

[英]WPF multipage Listview printing when using GroupStyle

I have coded up a ListView report using xaml, mvvm and it works just fine. 我已经使用xaml,mvvm编写了一个ListView报告,它工作得很好。 The xaml code deploys ListView.GroupStyle and the resulting report has a group header, items listing and group totals and counts. xaml代码部署ListView.GroupStyle ,生成的报告具有组标题,项目列表和组总计和计数。
It looks like this: 它看起来像这样: 在此输入图像描述

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. 我之前已阅读(并实践过)将ListView报告打印到固定页面/固定文档,并计算每个页面的项目源以将打印报告分布在多个页面上。

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. 我想我需要以某种方式构建报告作为单个未绑定(没有页面大小限制)ListView,拔出ListViewItems然后使用这些项来构建我的报告。

I have read solutions using FlowDocument , but do not see an answer there? 我已经使用FlowDocument阅读了解决方案 ,但是没有在那里看到答案?

Can anyone give me some ideas how to solve this problem? 任何人都可以给我一些想法如何解决这个问题?

Here is advice in the acepted answer to StackOverflow link you quoted: 以下是您引用的StackOverflow链接的附带答案中的建议:

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. 事实证明,flowdocument / XPS方法是一种完全错误的方式来处理这项任务,事实上,内置的RDLC报告使我们能够以相对直接的方式实现发票文档所需的一切。

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文章的链接,该文章打印带有重复标题的数据网格,如果您仍想继续使用oirignal方法,那么几乎就是您要问的内容:

CodeProject - Custom Data Grid Document Paginator CodeProject - 自定义数据网格文档Paginator

And there are several good answers with other approaches in this StackOverflow question - 在StackOverflow问题中,其他方法有几个很好的答案 -

StackOverflow - Whats the best approach to printing reporting from wpf StackOverflow - 什么是从wpf打印报告的最佳方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM