WPF: Animating TranslateTransform from code

前端 未结 4 863
梦如初夏
梦如初夏 2021-02-04 02:17

I have a WPF canvas on which I\'m dynamically creating objects from code. These objects are being transformed by setting the RenderTransform property, and an animation needs to

4条回答
  •  北海茫月
    2021-02-04 02:54

    Leave out the Storyboard:

    var T = new TranslateTransform(40, 0);
    Duration duration = new Duration(new TimeSpan(0, 0, 0, 1, 0));
    DoubleAnimation anim = new DoubleAnimation(30, duration);
    T.BeginAnimation(TranslateTransform.YProperty, anim);
    

    (small fix for syntax)

提交回复
热议问题