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.