使用 GroupStyle 时 WPF 多页 Listview 打印

标签 wpf listview printing groupstyle

我编写了一个 ListView使用 xaml,mvvm 报告,它工作得很好。
xaml 代码部署 ListView.GroupStyle生成的报告有一个组标题、项目列表和组总计和计数。
它看起来像这样:
enter image description here

我想将同样的报告打印到打印机上。它是多页的,单独的组可以跨越一页以上,具体取决于报告日期跨度。我还想在每个打印页面的顶部显示列标题。

我之前已经阅读(并练习过)将 ListView 报告打印到 FixedPage/Fixed Document 并计算每个页面的项目源以将打印的报告分布在多个页面上。

这次因为我用的是分组,问题就显得比较难了?我看不到如何计算每个页面的项目来源。我在想我需要以某种方式将报告构建为单个未绑定(bind)(无页面大小限制)ListView,取出 ListViewItems,然后使用这些项目来构建我的报告。

我已阅读 solutions using FlowDocument ,但在那里看不到答案?

谁能给我一些想法如何解决这个问题?

最佳答案

以下是您引用的 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.



这是我要走的路线。

这是 CodeProject 文章的链接,该文章打印带有重复标题的数据网格,这几乎就是您要问的,如果您仍想继续使用原始方法:

CodeProject - Custom Data Grid Document Paginator

在这个 StackOverflow 问题中,其他方法有几个很好的答案 -

StackOverflow - Whats the best approach to printing reporting from wpf

关于使用 GroupStyle 时 WPF 多页 Listview 打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17118442/

相关文章:

Android:ListView 监听器?

c - 在 C 中打印出文件名及其大小

wpf - 复选框中的复选标记

android - 过滤自定义ArrayAdapter或在 Activity 中实现搜索

android - 滚动后如何在 ListView 顶部显示完全可见的项目?

c# - 从 Windows 8 上的 Windows 服务打印失败

objective-c - 创建自动调整大小的打印输出

c++ - createprocess结束后如何从exe返回参数?

wpf - Fluent Ribbon SelectedTabItem 或 SelectedTabIndex

.net - 如何在 WPF 中使用全局资源?