问题描述
我有3个多边形我想点亮的基础上(改变不透明度)动态code。举例来说,我有随机数(021200112)的长字符串。我试图创建一个关键帧的动态故事板。我用一个多边形测试它,我得到一个目标误差。你的帮助是AP preciated!
多边形是在XAML(名为POLY 1,POLY2,Poly3)创建的。
下面是我的错误,当它试图播放情节提要:
WinRT的信息:不能指定对象上解决TargetProperty 1。
下面是我的code来测试POLY 1动画。
公用Sub PlayStoryboard() 昏暗myDoubleAnimationUsingKeyFrames作为新DoubleAnimationUsingKeyFrames()
昏暗myLinearDoubleKeyFrame作为新LinearDoubleKeyFrame()
昏暗myLinearDoubleKeyFrame2作为新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 =新的持续时间(TimeSpan.FromMilliseconds(5000)) 昏暗的myStoryboard =新故事板()
myStoryboard.Children.Add(myDoubleAnimationUsingKeyFrames) Storyboard.SetTarget(myDoubleAnimationUsingKeyFrames,POLY 1)
Storyboard.SetTargetName(myDoubleAnimationUsingKeyFrames,Poly1.Name)
Storyboard.SetTargetProperty(myDoubleAnimationUsingKeyFrames,不透明度) myStoryboard.Begin()结束小组
target属性,就是要在名称的属性动画(或者,更确切地说,一个的PropertyPath,但可以从字符串转换而来)。
请尝试以下操作:
Storyboard.SetTargetProperty(myDoubleAnimationUsingKeyFrames,透明度)
I have 3 polygons that I am trying to "light up" (changing opacity) based on dynamically code. For instance, I have a long string of random numbers (021200112). I'm trying to create a dynamic storyboard with keyframes. I'm testing it with a single polygon and I am getting a target error. Your help is appreciated!!!
The polygons are created in the XAML (named Poly1, Poly2, Poly3).
Here is my error when it tries to play the storyboard:
WinRT information: Cannot resolve TargetProperty 1 on specified object.
Here is my code to test the animation on 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
The target property is meant to be the name of the property to animate (or, more specifically, a PropertyPath, but that can be converted from a String).
Try the following:
Storyboard.SetTargetProperty(myDoubleAnimationUsingKeyFrames, "Opacity")
这篇关于XAML - 如何动态地创建一个DoubleAnimationUsingKeyFrames和VB玩故事板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!