How can you use ObjectAnimationUsingKeyFrames from pure C#?

前端 未结 1 738
耶瑟儿~
耶瑟儿~ 2021-01-28 15:28

I want to dynamically, from C#, do something like this:



        
相关标签:
1条回答
  • 2021-01-28 16:05

    Ok! I figured out the C# equivalent.

            ObjectAnimationUsingKeyFrames animation = new ObjectAnimationUsingKeyFrames();
            animation.BeginTime = TimeSpan.FromSeconds(0);
            Storyboard.SetTarget(animation, image);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(Image.Source)"));
            DiscreteObjectKeyFrame keyFrame = new DiscreteObjectKeyFrame(BitmapFrame.Create(uri), TimeSpan.FromSeconds(0.7));
            animation.KeyFrames.Add(keyFrame);
            myStoryboard.Children.Add(animation);
            myStoryboard.Begin();
    

    I used "SetTarget" instead of "SetTargetName"

    0 讨论(0)
提交回复
热议问题