<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.
什么发生了什么?
@H_301_4@解决方法 我自己想通了.我所要做的就是在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>
希望能节省一些时间!
@H_301_4@ @H_301_4@ @H_301_4@ @H_301_4@ 总结以上是内存溢出为你收集整理的c# – Storyboard DoubleAnimation不适用于StackPanel高度属性全部内容,希望文章能够帮你解决c# – Storyboard DoubleAnimation不适用于StackPanel高度属性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)