【发布时间】:2015-01-15 17:37:00
【问题描述】:
我正在尝试将此情节提要 xaml 标记转换为 vb 代码。但是,当我运行代码时,没有任何反应,没有引发异常或错误。我有什么遗漏吗?
从 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
标签: vb.net xaml windows-phone-8 windows-phone-8.1