我有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
答案 0 :(得分:1)
target属性是要设置动画的属性的名称(或者更具体地说,是PropertyPath,但可以从String转换)。
尝试以下方法:
Storyboard.SetTargetProperty(myDoubleAnimationUsingKeyFrames, "Opacity")