0
我有3個多邊形,我試圖根據動態代碼「點亮」(更改不透明度)。例如,我有一串很長的隨機數(021200112)。我正嘗試用關鍵幀創建動態故事板。我用一個多邊形測試它,我得到一個目標錯誤。您的幫助表示讚賞!XAML - 如何動態創建DoubleAnimationUsingKeyFrames並使用VB播放故事板?
多邊形是在XAML(名爲Poly1,Poly2,Poly3)中創建的。
這是我的錯誤,當它試圖扮演故事板:
WinRT information: Cannot resolve TargetProperty 1 on specified object.
這裏是我的代碼,以測試POLY1動畫。
Public Sub PlayStoryboard()
Dim myDoubleAnimationUsingKeyFrames As New DoubleAnimationUsingKeyFrames()
Dim myLinearDoubleKeyFrame As New LinearDoubleKeyFrame()
Dim myLinearDoubleKeyFrame2 As New LinearDoubleKeyFrame()
myLinearDoubleKeyFrame.Value = 0.2
myLinearDoubleKeyFrame.KeyTime = TimeSpan.FromSeconds(1)
myLinearDoubleKeyFrame2.Value = 1
myLinearDoubleKeyFrame2.KeyTime = TimeSpan.FromSeconds(3)
myDoubleAnimationUsingKeyFrames.KeyFrames.Add(myLinearDoubleKeyFrame)
myDoubleAnimationUsingKeyFrames.KeyFrames.Add(myLinearDoubleKeyFrame2)
myDoubleAnimationUsingKeyFrames.Duration = New Duration(TimeSpan.FromMilliseconds(5000))
Dim myStoryboard = New Storyboard()
myStoryboard.Children.Add(myDoubleAnimationUsingKeyFrames)
Storyboard.SetTarget(myDoubleAnimationUsingKeyFrames, Poly1)
Storyboard.SetTargetName(myDoubleAnimationUsingKeyFrames, Poly1.Name)
Storyboard.SetTargetProperty(myDoubleAnimationUsingKeyFrames, Opacity)
myStoryboard.Begin()
End Sub