问题
I'm trying to print my visual into a multipage xps. The first page is working but the others are left blank.
Dim xP As Integer = 0
Dim yP As Integer = 0
xP = Math.Ceiling(WorkFlowCanvas.Width / pageWidth)
yP = Math.Ceiling(WorkFlowCanvas.Height / pageHeight)
Dim collator = writer.CreateVisualsCollator()
collator.BeginBatchWrite()
For y = 1 To yP
For x = 1 To xP
Dim o As New Canvas
o = New CanvasCreator().GenerateCanvas()
Dim sv As New ScrollViewer
sv.Height = 1200
sv.Width = 800
sv.Content = o
sv.ScrollToHorizontalOffset(x - 1 * sv.Width)
sv.ScrollToVerticalOffset(y - 1 * sv.Height)
sv.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
sv.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled
collator.Write(sv)
Next
Next
collator.Write(Me)
collator.EndBatchWrite()
By making the visual in xaml and printing it I noticed the scrollviewer always scrolls the content up before writing it(the scrollbars don't move). Is there a way to 'freeze' the scrollviewer?
回答1:
This solution is hacky but it seems to work for me.
sv.IsEnabled = False
collator.Write(sv)
sv.IsEnabled = True
You can stil answer if you know why I have to do this.
来源:https://stackoverflow.com/questions/10981996/prevent-scrollviewer-from-scrolling-just-before-printing