自动平滑调整大小过渡 - 故事板的问题 [英] Automatic Smooth Resize Transitions - A Problem with Storyboards

查看:22
本文介绍了自动平滑调整大小过渡 - 故事板的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试创建一个类/一系列类,当检测到相关对象的大小调整时,会尝试停止对象的大小调整并为其创建平滑的调整大小动画.但是,在动画开始之前,我一直遇到对象在屏幕上以目标尺寸闪烁"一秒钟的问题.

I have been trying for some time to create a class/series of classes that, upon detecting a resize in a related object, attempts to halt the resize of the object and create a smooth resize animation for it. However, I have always had a problem with the objects 'flickering' on the screen for a second at the target size before the animation kicks in.

长话短说,经过一些认真的调试和自我怀疑,我的印象是调用 Storyboard.Begin() 不会影响目标值,直到下一个时钟滴答声.我认为这与 Storyboard.Seek() 直到下一个时钟滴答声才发生有关.(请参阅 MSDN 参考).因此,在动画开始之前,对象会采用单帧的新高度,将其拉回起始高度.

Long story short, after some serious debugging and self-doubt, I am under the impression that calling Storyboard.Begin() does not affect the target value until the next clock tick. I presume that this has something to do with Storyboard.Seek() not occuring until the next clock tick. (See the MSDN Reference). And as such, the object adopts its new height for a single frame before the animation kicks in which pulls it back to the starting height.

我花了很长时间试图让它发挥作用,因为它远没有看起来那么简单.我无法在 FrameworkElement.SizeChanged 事件处理程序中将 FrameworkElement.Height 设置为 e.PreviousSize.Height,因为这会影响 'true' 物体的高度.作为为什么这不起作用的一个例子,如果在播放动画时改变了对象的真实"高度,则将 FrameworkElement.Height 重新设置为收集的目标高度动画开始时可以将其设置为不正确的过时值.

I have spent a long time trying to get this working because it's not nearly as simple as it seems. I can't set FrameworkElement.Height to the e.PreviousSize.Height in a FrameworkElement.SizeChanged event handler, because that affects the 'true' height of the object. As an example of why this doesn't work, is if something changes the 'true' height of the object while the animation is playing, then re-setting FrameworkElement.Height to the target height that was collected when the animation began could set it as an incorrect, out-dated value.

我尝试了更多的东西,我相信它们会随着答案的出现而出现,但您的任何想法都将不胜感激.

There's more things I've tried, and I'm sure they'll come up as answers arrive, but any ideas you have will be very much appreciated.

推荐答案

通过创建一个布局容器来处理子对象的大小调整,您可能会获得更好的运气,例如 Robby Ingebretsen 的动画面板.

You'd probably have better luck by creating a layout container that handles the resize of the child objects, something like Robby Ingebretsen's Animated Panel.

这篇关于自动平滑调整大小过渡 - 故事板的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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