防止 Scrollviewer 在打印前滚动? [英] Prevent Scrollviewer from Scrolling just before printing?

查看:34
本文介绍了防止 Scrollviewer 在打印前滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的视觉效果打印到多页 xps 中.第一页正在工作,但其他页面留空.

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()

通过在 xaml 中制作视觉效果并打印它,我注意到滚动查看器总是在写入内容之前向上滚动内容(滚动条不会移动).有没有办法冻结"滚动查看器?

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?

推荐答案

这个解决方案很笨拙,但似乎对我有用.

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.

这篇关于防止 Scrollviewer 在打印前滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆