问题描述
我正在尝试使用 DoubleAnimation 来更改 StackPanel 的 Height 属性.该代码不会引发任何异常.但是动画不起作用.
I'm trying to use DoubleAnimation to change the Height property of a StackPanel. The code does not throw any exception. But the animation does not work.
C# 事件处理程序
它确实命中了 ChangePasswordHeader_Tapped 事件处理程序并按预期执行 ShowStackPanel.Begin 或 HideStackPanel.Begin 语句.但这对输出没有任何影响.StackPanel 的高度保持在 0.
It does hit ChangePasswordHeader_Tapped event handler and execute ShowStackPanel.Begin or HideStackPanel.Begin statement as expected. But it does not have any impact on the output. The Height of the StackPanel just stays at 0.
知道发生了什么吗?
推荐答案
我自己想通了.我所要做的就是在 DoubleAnimation 上启用依赖动画 (EnableDependentAnimation),因为此动画会影响布局.然后它完美地工作了.
I figured it out myself. All I had to do was to Enable Dependent Animation (EnableDependentAnimation) on the DoubleAnimation as this animation affects the layout. And then it worked perfectly.
希望它能节省一些时间!
Hope it saves someone some time!
这篇关于Storyboard DoubleAnimation 不适用于 StackPanel Height 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!