我有 3 个多边形,我试图根据动态代码“点亮”(改变不透明度)。例如,我有一长串随机数(021200112)。我正在尝试使用关键帧创建动态故事板。我正在使用单个多边形对其进行测试,但出现了目标错误。感谢您的帮助!!!
多边形在 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