如何强制滚动条滚动画布
我想知道是否有任何方法可以强制滚动条滚动画布。 我将画布放置在滚动视图中,并覆盖了measureoverride方法。当我到达画布可见部分的末端时,会显示滚动条。不过,我希望画布滚动,因为现在,尽管滚动条显示,但画布不跟随项目。我希望你能理解我,抱歉我的英语不好:)
I was wondering if there is any way to force a scrollbar to scroll a canvas.
I placed canvas in scrollview and I overrode the measureoverride method. Scrollbars show when I reach the ends of visible parts of the canvas. However I would like the canvas to scroll because now, despite the fact that scrollbars show, the canvas does not follow item. I hope you understand me, sorry for my bad English :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让我尝试一下,
1)您在滚动查看器中托管了一个画布。
2) 当画布尺寸增大时,会出现滚动查看器。 [由于您已将水平或垂直滚动条可见性设置为自动]
3)你想要的是,当你到达画布的末尾时[画布的大小增加,因此滚动查看器的滚动条将会出现。]你希望滚动查看器的滚动条自动滚动以显示额外的空间。
如果,上面的问题是对的。答案就在这里。
您必须根据画布的 ActualWidth 或 ActualHeight 进行计算,并相应地将值设置为 ScrollToHorizontalOffset 或 ScrollToVerticalOffset 属性。
Let me try,
1) You have a hosted a canvas inside a scroll viewer.
2) When the canvas size increases, the scroll viewer is appearing. [Since, you have set the horizontal or vertical scrollbar visibility to auto]
3) What you want is, When you reach the end of the canvas [Size of canvas gets increases, so scroll bars of scroll viewer will appear.] you want the scroll bar of the scroll viewer to scroll automatically to show the extra space.
If, the above question is right. Here goes, the answer.
You have to do a calculation based on the ActualWidth or ActualHeight of the canvas and set the value to the
ScrollToHorizontalOffset
orScrollToVerticalOffset
property accordingly.下面的示例将在蓝色画布中显示一个红色圆圈,如果它不适合窗口,它将有垂直和水平滚动条。
Below sample will show a red circle in a blue canvas which will have vertical and horizontal scrollbars if it don't fit in the window.