CSharp examples for Windows.UI.Xaml.Media.Animation:Animation
Create Translate Rotation Effects
using Windows.UI.Xaml.Media.Animation; using Windows.UI.Xaml; using Windows.UI; using System;//from w w w. j a v a 2 s . c o m public class Main{ public static Storyboard CreateTranslateRotationEffects( DependencyObject target, TimeSpan beginTime, Duration duration, double translateXFrom, double translateXTo, double translateYFrom, double translateYTo, double rotationTo, double opacityTo = 0) { var translateX = new DoubleAnimation { BeginTime = beginTime, Duration = duration, From = translateXFrom, To = translateXTo, }; var translateY = new DoubleAnimation { BeginTime = beginTime, Duration = duration, From = translateYFrom, To = translateYTo, }; var opacity = new DoubleAnimation { BeginTime = beginTime, Duration = duration, To = opacityTo, }; var rotation = new DoubleAnimation { BeginTime = beginTime, Duration = duration, To = rotationTo, }; Storyboard.SetTarget(translateX, target); Storyboard.SetTargetProperty(translateX, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)"); Storyboard.SetTarget(translateY, target); Storyboard.SetTargetProperty(translateY, "(UIElement.RenderTransform).(CompositeTransform.TranslateY)"); Storyboard.SetTarget(opacity, target); Storyboard.SetTargetProperty(opacity, "Opacity"); Storyboard.SetTarget(rotation, target); Storyboard.SetTargetProperty(rotation, "(UIElement.RenderTransform).(CompositeTransform.Rotation)"); var sb = new Storyboard(); sb.Children.Add(translateX); sb.Children.Add(translateY); sb.Children.Add(opacity); sb.Children.Add(rotation); return sb; } }