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

Convert Animation from XAML to C#
soulfhd
atisoft
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);