I am looking for an idea of a clean generic way to describe repeating page headers and footers in a XAML FlowDocument without any code behind. It only needs to show up correctly when rendered to XPS from C#.
How to create a Xaml FlowDocument with Page Headers and Footers when rendered to XPS?
11.5k views Asked by jbtule At
1
There are 1 answers
Related Questions in C#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in WPF
- Sorting a List by its property renames all the objects in the List
- Can't open new instance of another window in my app, in WPF .NET 8
- Binding forecolour and ToolTip to a DataGrid
- how to create Infinite Upgrades in a clicker game
- Try Catch exception is not catching the unhandled exception
- Assigning an object to another doesn't raise PropertyChanged event in WPF
- Masking input in TextBox
- What should I do if Visual Studio has a restriction on creating files with a long name or a long path to these files?
- reading configuration file (mytest.exe.config)
- WPF Windows Initializing is locking the separated thread in .Net 8
- How to bind to the DataContext ViewModel of another view?
- mouse coordinates in image go below 0 and above width
- WPF pop up is behaving differently in English language PC and Japanese language PC
- Multi level project reference using dll
- Unable to unzip archive .NET framework
Related Questions in XAML
- Can't open new instance of another window in my app, in WPF .NET 8
- Visual Studio throwing DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION when I try to add a log
- Deeplinking in .net Maui "Window was allready created"
- MauiApp crashes only in release mode at sideswitch android.os.DeadObjectException
- Move .net maui contents below the drawer when it's opened
- Both `TouchBehavior.CommandParameter` and `TouchBehavior.LongPressCommandParameter` are always passed as `null` to `Command` and `LongPressCommand`
- How do I change the size of a window?
- How can I force a .NET MAUI ContentView to fill the entire remaining space of its FlexLayout parent?
- How can I get this ComboBox to bind, populate the dropdown and write back selected value on update?
- MAUI-Animating each element of a BindableLayout
- Correctly set RadioButtonGroup for CollectionView in .NET MAUI
- Multiple color schemes depending on build configuration in WPF-application
- Select XAML file based on build configuration (Visual Studio 2022, WPF)
- The type was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built
- How can I tell if a control is actually Visible in UWP?
Related Questions in .NET-4.0
- How to establish 1:1 relationship with 2 composite keys in EF6 (not core)
- Windows Forms cloning buttons/forms keeps cloning many times
- Containerize a .net framework 4.5.1 mvc template app give error on permissions
- Changing .NET runtime at runtime
- Where does System.Security.Cryptography.RijndaelManaged..ctor() call come from (HASP-wrapped DLL)?
- Code analysis only shows CSxxx and IDExxx notes I see no CAxxx messages
- Local Reports in Visual Studio 2022
- Update Telerik.DataAccess.Core 2015.1.225.1 Assemblies to most recent nuget package
- Ps command not running under windows service
- NET Framework 4.0 breaks Com Interop - vb6 calling c# dll failing when changing target framework from 3.5 to 4.0 or higher
- Why is IHttpHandler's ProcessRequest method not getting the original URL in the context in .NET Framework?
- Sending email via Outlook365 from VB6/VB.net 4.0 application
- iTextSharp not protecting PDF with password
- System.IO.FileNotFoundException: Unable to load file or assembly Microsoft.SqlServer.Management.SqlParser
- Extract ECDSA non-exportable private key from x509 certificate
Related Questions in FLOWDOCUMENT
- How to detect Sections that are visible FlowDocumentScrollViewer view?
- Why it throw an error when integrating a table in the FlowDocument?
- How to print flowDocument to PDF without specifying file name
- How to convert a FlowDocument or XPS to PDF using C# .NET in 2023
- How to load a FlowDocument for viewing in PowerShell
- Disable Zoom in FlowDocument
- How to show an image inside a DocumentPaginator in WPF
- C# WPF Print page number on every page of a flow document
- How to save document with resource references?
- FlowDocumentScrollViewer does not display text (WPF, XAML)
- How can I successfully change WinForms hosted WPF RichTextBox Document Width? Document Width does not increase and wraps all text on reaching width
- FlowDocument (XPS) with Windows Update KB5020880 (CVE-2022-41089)
- How to get all selected TableCell from a Table in WPF RichTextBox? I tried to get all TableCell by using TextSelection but this gives wrong results
- WPF MouseLeftButtonDown makes FlowDocument unable to select text
- Flow Document Table c# WPF column span to take the space of next column if available
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I had the same problem a few months ago, and found these links very helpful: WPF Multipage Reports Part IV Pagination http://www.codeproject.com/KB/WPF/PimpedDocumentPaginator.aspx
The basic technique I used was to create a custom paginator by deriving from
DynamicDocumentPaginatoras follows:In my case,
THeaderFooterModelandTFooterModelare subclasses of aPageNumberModeltype as I needed the header or footer to be able to show the current page number.The custom paginator delegates to the original XPS paginator to do the majority of its work, so it stores it away in the constructor.
The
THeaderModelandTFooterModeltypes allow the paginator to retrieve XAMLDataTemplatesfor each type, which is what allows you to specify the layout of the header and footer in XAML without resorting to custom drawing code.In my code, the header and footer are of a fixed size, so when the paginator is created it retrieves the header and footer templates to determine how much space to reserve.
In the example code in the links provided, the technique they use to reserve space for the header and footer is to use a scale transform to shrink the original content. Instead, I tell the original paginator to use a reduced page size and then add the page the original paginator generates to a
ContainerVisualand set itsOffset. You probably couldn't do this if the size of the headers and footers was dynamic because the page count would keep changing.The only other complication I can recall was that you need to use the
Dispatcherqueue when adding headers and footers (seeAddHeaderOrFooterToContainerAsyncbelow). Data binding doesn't work otherwise. We are slightly subverting the WPF rendering model to get this to work.This would all be quite hard to explain without including the code so I've attached the custom renderer code below. I've stripped out some irrelevant stuff so if it doesn't compile as is that's probably why :-)
Note that the page number offset is passed in because our XPS document is comprised of multiple FlowDocument sections and the calling code keeps track of the current overall page number.
Hope this helps!