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