显示具有重复标题的多页 FlowDocument
我正在尝试将页眉/页脚添加到 WPF FlowDocument
中。我在互联网此处找到了一个解决方案,该解决方案使用自定义分页器类来做这个。不幸的是,这仅在打印文档时有效,这不是我打算做的。我的想法是使用 FlowDocumentPageReader 或类似的自定义分页器,但不知何故我不知道如何做到这一点,也许任何人都可以给我正确方向的提示。
I am trying to add Headers / footers to a WPF FlowDocument
. I Found a solution on the Internet here that is using a custom Paginator Class to do this. Unfortunately this only works when printing out the Document, which is not what I intend to do. My Idea was to use a FlowDocumentPageReader or something similar with a custom paginator, but somehow I can't figure out how I would do that, maybe anyone can give me a hint in the right Direction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只是显示 FlowDocument 而不是打印它,则可以通过为 FlowDocumentPageViewer 创建控件模板来实现页眉和页脚。
在模板中,将文本块放置在 DocumentPageView 的上方和下方,并将它们绑定到适当的值。
例如,如果您想要页码:
等等作为标题等。
您可以用边框包裹文本块和 DocumentPageView,以便整个内容显示为一页。
If you are just displaying the FlowDocument and not printing it, you can implement headers and footers by creating a control template for the FlowDocumentPageViewer.
In the template, place textblocks above and below the DocumentPageView, and bind them to the appropriate values.
For example, if you want a page number:
and so on for title, etc.
You can wrap the textblocks and DocumentPageView with a border so the whole thing appears as one page.