如何在动画过程中冻结控件上的滚动? [英] How to freeze scroll on a control during animation?
问题描述
C#,WinForms,我制作了自己的 UserControl
名为 ListOfControls
,它需要其他控件
并像垂直布局一样显示它们:
C#, WinForms, I made my own UserControl
named ListOfControls
that takes other controls
and displays them like a vertical layout like so:
|-------------------|
| Control 1 |
|-------------------|
|-------------------|
| Control 2 |
|-------------------|
|-------------------|
| Control 3 |
|-------------------|
如您所想,列表很大,所以我使用了 AutoScroll $ c
ListOfControls
上的$ c>。例如,现在有时候我想在运行时交换 Control 1
和 26
。因为 Control 26
远低于当前可见区域(用户仅看到前9个控件,然后他必须滚动),所以我必须考虑 VerticalScroll。
ListOfControls
As you imagine, list gets large so I apllied AutoScroll
on ListOfControls
. Now sometimes I want to swap Control 1
and 26
at runtime, for example. Because Control 26
is way below current visible area (user sees only first 9 controls, then he has to scroll) I have to account for the VerticalScroll.Value
of the ListOfControls
的值这是要抓住的地方:控件交换动画化(控件1
向下移动,控件26
向上移动)和 AutoScroll
已启用,因此在动画过程中滚动尝试对其进行说明,但最终完全弄乱了控件的最终位置。
And here is the catch: Swapping of controls is animated (Control 1
moves down, Control 26
moves up) and AutoScroll
is enabled so during the animation the scroll tries to account for it but in the end totally messes up the Control's final location.
反正还有冻结冻结滚动的方法吗?
Is there anyway how to freeze the scroll at its current position and wait for the animation to finish?
推荐答案
为了防止在移动时发生AutoScroll烟花控制,最好是自己控制环境。将AutoScroll属性设置为false,并将AutoScrollMinSize属性设置为控件所占用的画布大小。
In order to prevent the AutoScroll fireworks that happens when you are moving controls, it is best to control the environment yourself. Set the AutoScroll property to false and set the AutoScrollMinSize property to the size of canvas your controls are occupying.
这篇关于如何在动画过程中冻结控件上的滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!