wpf DoubleAnimation对image控件进行缩放旋转

 /// 
        /// 用户控件是的动画 缩放效果
        /// 
        /// 控件名
        /// 元素开始的大小
        /// 元素到达的大小
        public void ScaleEasingAnimationShow(UIElement element, double from, double to)
        {

            RotateTransform angle = new RotateTransform();  //旋转
            ScaleTransform scale = new ScaleTransform();   //缩放
           


            TransformGroup group = new TransformGroup();
            group.Children.Add(scale);
            group.Children.Add(angle);


            element.RenderTransform = group;
            element.RenderTransformOrigin = new System.Windows.Point(0.5, 0.5);//定义圆心位置        
            EasingFunctionBase easeFunction = new PowerEase()
            {
                EasingMode = EasingMode.EaseInOut,
                Power = 2
            };
            DoubleAnimation scaleAnimation = new DoubleAnimation()
            {
                From = from,                                   //起始值
                To = to,                                     //结束值
                EasingFunction = easeFunction,                    //缓动函数
                Duration = new TimeSpan(0, 0, 0, 5, 0),  //动画播放时间


            };

            DoubleAnimation angleAnimation = new DoubleAnimation()
            {
                From = 0,                                   //起始值
                To = 360,                                     //结束值
                EasingFunction = easeFunction,                    //缓动函数
                Duration = new TimeSpan(0, 0, 0, 5, 0),  //动画播放时间

            };

            //scaleAnimation.Completed += new EventHandler(scaleAnimation_Completed);
            //  AnimationClock clock = scaleAnimation.CreateClock();
            scale.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            scale.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            angle.BeginAnimation(RotateTransform.AngleProperty, angleAnimation);
            //}
        }

你可能感兴趣的:(C#)