0
我试图将这个故事板xaml标记转换为vb代码。但是,当我运行代码没有任何反应时,没有异常引发或错误没有任何东西。有什么我失踪?难以让DoubleAnimationUsingKeyFrames工作
从xaml运行时,故事板按预期工作,但是在我的代码隐藏翻译过程中出现了问题。
最后,我可以验证连接到故事板的目标元素确实存在。
XMAL
<Storyboard x:Name="FlipAnimation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="Front">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="Back">
<EasingDoubleKeyFrame KeyTime="0" Value="-90"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="-90"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
后面的代码
Dim firstKf As DoubleAnimationUsingKeyFrames = New DoubleAnimationUsingKeyFrames
firstKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.Zero, .Value = "0"})
firstKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.FromMilliseconds(200), .Value = "90"})
Media.Animation.Storyboard.SetTargetProperty(firstKf, New PropertyPath(PlaneProjection.RotationYProperty))
Media.Animation.Storyboard.SetTarget(firstKf, front)
Dim secondKf As DoubleAnimationUsingKeyFrames = New DoubleAnimationUsingKeyFrames
secondKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.Zero, .Value = "-90"})
secondKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.FromMilliseconds(200), .Value = "-90"})
secondKf.KeyFrames.Add(New EasingDoubleKeyFrame With {.KeyTime = TimeSpan.FromMilliseconds(400), .Value = "0"})
Media.Animation.Storyboard.SetTargetProperty(secondKf, New PropertyPath(PlaneProjection.RotationYProperty))
Media.Animation.Storyboard.SetTarget(secondKf, back)
Dim sb = New Media.Animation.Storyboard
sb.Children.Add(firstKf)
sb.Children.Add(secondKf)
sb.Begin()
尝试将'duration'设置为'firstKf' – safi 2015-01-15 21:23:47