WPF Visual to XPS document method creates only one page

920 views Asked by At

I have a WPF Window that I want to save to an XPS file (or really, any type of file that would store the window image). This window contains a lengthy DataGrid. So far I am able to write to an XPS file, but the resulting document contains only one page, so most of the DataGrid rows are missing. How can I get the XPSDocumentWriter to use as many pages as necessary?

Here is what I've got so far (I've turned off the grid scroll bar and autosized the window to make sure it is full-sized before writing to XPS file):

Dim visual = CType(Me.Content, Media.Visual)

            Me.LogGrid.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden
            Me.SizeToContent = Windows.SizeToContent.WidthAndHeight

            Dim xd As New System.Windows.Xps.Packaging.XpsDocument(file, IO.FileAccess.ReadWrite)

            Dim xw = System.Windows.Xps.Packaging.XpsDocument.CreateXpsDocumentWriter(xd)
            xw.Write(visual)
            xd.Close()
1

There are 1 answers

0
Tekito On BEST ANSWER

I think Will's comment is probably the right answer.