简体   繁体   English

如何在WPF中触发情节提要的特定部分?

[英]How do I trigger specific parts of a storyboard in WPF?

I have several grids in my window. 我的窗户上有几个网格。 I have created a storyboard that moves them left by x pixels when a button is clicked. 我创建了一个情节提要,单击按钮时将其向左移动x像素。 I want to make it so that when the button is clicked again those grids move another x pixels, however I'm unable to find out how to do this as it's not a common task on tutorials. 我想这样做,以便再次单击该按钮时,那些网格又移动了x像素,但是我无法找到如何执行此操作的方法,因为这在教程中并不常见。

I have tried creating a second storyboard to do this, however that won't work as then the grids will be back at their starting positions. 我尝试创建第二个情节提要板来执行此操作,但是那样将无法正常工作,因为网格将恢复到其初始位置。

One solution might be to create a third set of keyframes after the first two sets, and somehow pause the animation when it gets there, and resumes it again when the button is clicked, however I'm not sure how to pause a storyboard when it reaches a keyframe. 一种解决方案可能是在前两套动画之后创建第三套关键帧,然后以某种方式暂停动画,然后在单击按钮时再次将其恢复,但是我不确定如何在此动画演示板上暂停到达关键帧。 This would also make reversing the grids difficult (using this approach http://social.msdn.microsoft.com/forums/en-US/wpf/thread/ac54de71-f750-4940-91a2-231810308727/ ), as I'd like to make another button make the grids go the other way. 如我所愿,这也将使反转网格变得困难(使用此方法http://social.msdn.microsoft.com/forums/en-US/wpf/thread/ac54de71-f750-4940-91a2-231810308727/ )想要使另一个按钮使网格朝相反方向移动。

I think the answer to this question in WPF is that you can't. 我认为WPF中此问题的答案是您不能这样做。 WPF (AFAIK) does not allow you to repetitively TranslateTransform an object. WPF(AFAIK)不允许您重复TranslateTransform对象。 You would need to keep track of where it is, and manage the positions of each which is messy. 您将需要跟踪它的位置,并管理每个位置的位置。

I found this control which is what I was looking for: http://bot.codeplex.com/ (the Zap Scrollbar) 我找到了我想要的控件: http : //bot.codeplex.com/ (Zap滚动条)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM