How to repeat table headers on multiple pages in WPF
I am using WPF to design a standalone application which allows users to enter details on the GUI. The view option on the application talks to WORD and displays the details entered by the user on respective fields on WORD ( like a FORM).
One of the features is a table with four columns. On the GUI , users can enter any number of rows. If there are 100 rows, the corresponding rows in WORD should display on two or more pages with the table headers of the table repeating on multiple pages
How can table headers be repeated on multiple pages in WPF?
This is a feature that is not really supported.
You might be able to grab the page visuals and insert your header info into the DocumentPages. This is a pretty advanced concept though.
Hi wisper_leaf... to be clear, are you trying to repeat the table headers in a FlowDocument? FixedDocument?
Depending on your scenario, there may not be a need to place the content in a document. If this is the case, there are some other UI elements that may be more appropriate.
FlowDocument currently has no support for headers or footers. If there is some information you need to display at the top/bottom of every page, it's best to put this in the control template of the viewer you are using to display the document. For example, here's a really basic template for a FlowDocumentPageViewer, with comments about where you would put this data:
<FlowDocumentPageViewer.Template>
<
ControlTemplate TargetType="{x:Type FlowDocumentPageViewer}"> <!-- PUT HEADER HERE -->
<AdornerDecorator>
<DocumentPageView FlowDocumentPageViewer.IsMasterPage="True" />
</AdornerDecorator>
<!-- PUT FOOTER HERE -->
</
ControlTemplate> </
FlowDocumentPageViewer.Template> If you want what's displayed in the header/footer to change depending on what page it is, you can use data binding to bind to properties on the page viewer (if it's something simple like just displaying the page number itself) or actually writing code to listen for changes on the veiwer's MasterPageNumber and change the content of the control.
I would recommend doing this over trying to modify the FlowDocument itself.