Convert Animation from XAML to C#

I’m trying to convert this XAML code to C# code, to be able to add my animations at runtime. What happens is that the C# code is semantically correct, but the “c# animation” does not begin. The same XAML code works instead.

Am I missing something

Thanks

Giorgio


Answer this question

Convert Animation from XAML to C#

  • soulfhd

    Are you converting by hand I am looking for some tool that will help me do that.

  • atisoft

    I noticed you didn't set the duration of 'anim'. I didn't test it, but it's something to try.
  • Kenneth Clapp

    I'm not up to speed on WPF animation, but try attaching it to your UI, worked for me when I translated animation from XAML to C#.

    Name the rectangle in XAML.

      Name="MyRectangle"

    Call the BeginStoryboard on with the rectangle in code behind.

      BeginStoryboard(MyRectangle, true);



  • Convert Animation from XAML to C#