Question

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()
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top