0

動的コードに基づいて「ライトアップ」(不透明度の変更) しようとしている 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
4

1 に答える 1

1

ターゲット プロパティは、アニメーション化するプロパティの名前です (より具体的には、PropertyPath ですが、文字列から変換できます)。

次のことを試してください。

Storyboard.SetTargetProperty(myDoubleAnimationUsingKeyFrames, "Opacity")
于 2012-09-07T16:29:58.550 に答える