WPF Animation without XAML

Now why would anyone want to do WPF animation without XAML? In my case I started writing in F# and could not data-bind F# types to XAML. Eventually it turned out that converting F# code to C# was easier. But still for the really curious the following code does PointAnimation of the GradientOriginProperty of a RadialGradientBrush. I don’t claim to understand why we need to go through so many hops. I’ll update this blog when I do.

private void Anim(RadialGradientBrush br, 
                  Point dest, 
                  String tarName )
  PointAnimation animation = new PointAnimation();
  animation.To = dest;
  Storyboard.SetTargetName(animation, tarName);
       new PropertyPath(
  NameScope nams = new NameScope();
  NameScope.SetNameScope(this, nams);
  this.RegisterName(tarName, br);
  Storyboard stboard = new Storyboard();

About The Sunday Programmer

Joe is an experienced C++/C# developer on Windows. Currently looking out for an opening in C/C++ on Windows or Linux.
This entry was posted in .NET, WPF. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s