c# – Storyboard DoubleAnimation不适用于StackPanel高度属性
发布时间:2020-12-16 00:21:51 所属栏目:百科 来源:网络整理
导读:我正在尝试使用DoubleAnimation来更改StackPanel的Height属性.代码不会抛出任何异常.但动画不起作用. StackPanel x:Name="FlyoutContent" StackPanel.Resources Storyboard x:Name="HideStackPanel" DoubleAnimation Storyboard.TargetName="ChangePasswordP
我正在尝试使用DoubleAnimation来更改StackPanel的Height属性.代码不会抛出任何异常.但动画不起作用.
<StackPanel x:Name="FlyoutContent"> <StackPanel.Resources> <Storyboard x:Name="HideStackPanel"> <DoubleAnimation Storyboard.TargetName="ChangePasswordPanel" Storyboard.TargetProperty="Height" From="190" To="0" Duration="0:0:1"> <DoubleAnimation.EasingFunction> <PowerEase EasingMode="EaseIn"></PowerEase> </DoubleAnimation.EasingFunction> </DoubleAnimation> </Storyboard> <Storyboard x:Name="ShowStackPanel"> <DoubleAnimation Storyboard.TargetName="ChangePasswordPanel" Storyboard.TargetProperty="Height" From="0" To="190" Duration="0:0:1"> <DoubleAnimation.EasingFunction> <PowerEase EasingMode="EaseIn"></PowerEase> </DoubleAnimation.EasingFunction> </DoubleAnimation> </Storyboard> </StackPanel.Resources> <TextBlock Margin="0,20,0" FontWeight="Bold" Text="Change Current Password" TextWrapping="Wrap" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" IsTapEnabled="True" Tapped="ChangePasswordHeader_Tapped"/> <StackPanel x:Name="ChangePasswordPanel" Margin="0,5,0" Height="0"> C#事件处理程序 private void ChangePasswordHeader_Tapped(object sender,TappedRoutedEventArgs e) { if (ChangePasswordPanel.Height == 0) { ShowStackPanel.Begin(); } else { HideStackPanel.Begin(); } } 它确实命中了ChangePasswordHeader_Tapped事件处理程序并按预期执行ShowStackPanel.Begin或HideStackPanel.Begin语句.但它对输出没有任何影响. StackPanel的高度保持为0. 什么发生了什么? 解决方法
我自己想通了.我所要做的就是在DoubleAnimation上启用相关动画(EnableDependentAnimation),因为此动画会影响布局.然后它完美地工作.
<Storyboard x:Name="HideChangePasswordPanel"> <DoubleAnimation EnableDependentAnimation="True" Storyboard.TargetName="ChangePasswordPanel" Storyboard.TargetProperty="Height" From="190" To="0" Duration="0:0:0.2"> <DoubleAnimation.EasingFunction> <PowerEase EasingMode="EaseIn"></PowerEase> </DoubleAnimation.EasingFunction> </DoubleAnimation> </Storyboard> <Storyboard x:Name="ShowChangePasswordPanel"> <DoubleAnimation EnableDependentAnimation="True" Storyboard.TargetName="ChangePasswordPanel" Storyboard.TargetProperty="Height" From="0" To="190" Duration="0:0:0.2"> <DoubleAnimation.EasingFunction> <PowerEase EasingMode="EaseIn"></PowerEase> </DoubleAnimation.EasingFunction> </DoubleAnimation> </Storyboard> 希望能节省一些时间! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何在ruby中导航两个目录
- 如何在Flex应用程序中嵌入“Share on Facebook”按钮?
- ruby-on-rails – 如何使用RSpec和Rails 4测试子域约束
- iOS中使用正则表达式NSRegularExpression 来验证textfiled输
- 在C API中定义的类型如何将它与命名空间中的C类相关联?
- Vue中"This dependency was not found"问题的解决方
- NOSQL-Mongodb
- git提示“warning: LF will be replaced by CRLF”
- notepad++ 正则表达式 应用案例1
- ruby-on-rails – Rails Rich Associations – 未定义的方法