Skip to content

Instantly share code, notes, and snippets.

@dgkanatsios
Created July 25, 2014 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgkanatsios/3a52052bf4236b754c62 to your computer and use it in GitHub Desktop.
Save dgkanatsios/3a52052bf4236b754c62 to your computer and use it in GitHub Desktop.
A snippet to create a 0 to 1 opacity Storyboard for Windows Phone
public static Storyboard CreateOpacityStoryboard(FrameworkElement element)
{
Storyboard sb = new Storyboard();
DoubleAnimation opacityAnimation = new DoubleAnimation();
opacityAnimation.From = 0;
opacityAnimation.To = 1;
opacityAnimation.Duration = TimeSpan.FromMilliseconds(300);
Storyboard.SetTarget(opacityAnimation, element);
Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("(FrameworkElement.Opacity)"));
sb.Children.Add(opacityAnimation);
sb.Begin();
return sb;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment