如何为元素的出现设置动画
我有一个关于 Expression Blend 4 的问题。
我想创建一个简单的组件出现动画,当组件的高度从 0 变化到 100% 并且其下方的组件向下移动以分配所需的空间时。
我的问题是只有像素中的静态值才允许创建这种类型的动画。但我不知道我的控件的高度(实际上,它是文本框,其中内容和内容长度可能会有所不同),并且我无法将最后一个关键帧的 Height
值设置为 Auto
。
为了实现这个任务我应该做什么?
提前致谢。
I have an question about Expression Blend 4.
I want to create a simple component appearing animation, when height of component changes from 0 to 100% and components below it are moving down to allocate required space.
My problem is that only static values in pixels allowed to create such type of animation. But I did not know height of my control (actually, it is textBox in which content and content length may vary), and I cannot set Height
value of last keyframe to Auto
.
What should I do to implement this task?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想最简单的方法是使用
流体布局
。在下面的示例中,我创建了一个
TextBlock
并将其Visibility
设置为Collpased
。然后,当触发Show
视觉状态时,我将其Visibility
设置为Visible
。通常,您无法为Visibility
设置动画,但如果启用Fluid Layout
行为(另请记住定义TransitionEffect
),它将为其设置动画自动为您服务。当然,如果您不想使用这个神奇的动画,您可以尝试对其
ScaleY 进行动画处理
。类似这样的事情,希望这有帮助! :)
I guess the easist way would be using the
Fluid Layout
.In the below example I created a
TextBlock
and set itsVisibility
toCollpased
. Then when theShow
visual state is triggered, I set itsVisibility
toVisible
. Normally you can't animate theVisibility
but if you enable theFluid Layout
behavior (also remember to define aTransitionEffect
), it will animate it for you automatically.Of course if you don't want to use this magicial animation you can try animating its
ScaleY
. Something like this,Hope this helps! :)