标签:
var composition = ElementCompositionPreview.GetElementVisual(this).Compositor;
//-------------------------------------------------------------------- // 1.创建一个ScalarAnimation和一个线性缓动函数。 //-------------------------------------------------------------------- var animation = composition.CreateScalarKeyFrameAnimation(); var easing = composition.CreateLinearEasingFunction(); //-------------------------------------------------------------------- // 1.设置动画,从0度旋转360度,3秒钟,重复播放 //-------------------------------------------------------------------- animation.InsertKeyFrame(0.0f,0.0f); animation.InsertKeyFrame(1.0f,360.0f,easing); animation.Duration = TimeSpan.FromMilliseconds(3000); animation.IterationBehavior = AnimationIterationBehavior.Forever;
//-------------------------------------------------------------------- // 1.获取button的Visual // 2.开始动画,中心旋转 //-------------------------------------------------------------------- var buttonVisual = ElementCompositionPreview.GetElementVisual(AnimatingButton); buttonVisual.CenterPoint = new Vector3((float)AnimatingButton.ActualWidth/2.0f,(float)AnimatingButton.ActualHeight/2.0f,0.0f); buttonVisual.StartAnimation(nameof(buttonVisual.RotationAngleInDegrees),animation);
标签:
原文地址:http://www.cnblogs.com/Enious/p/5927879.html