Displaying a Multi-Paged FlowDocument with repeating Headers

 ̄綄美尐妖づ 提交于 2019-12-24 11:01:18

问题


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.


回答1:


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:

<TextBlock Text="{Binding Path=MasterPageNumber, RelativeSource={RelativeSource TemplatedParent}" FontSize="14" FontWeight="Bold" />

and so on for title, etc.

You can wrap the textblocks and DocumentPageView with a border so the whole thing appears as one page.



来源:https://stackoverflow.com/questions/3235664/displaying-a-multi-paged-flowdocument-with-repeating-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!