Ejemplo n.º 1
1
        /// <summary>
        /// 动态显示内容
        /// </summary>
        /// <param name="target"></param>
        /// <param name="duration"></param>
        public static void Show(ContentControl target, double duration = .8)
        {

            ThicknessAnimation animtion = new ThicknessAnimation()
            {
                From = new Thickness(target.Margin.Left + 80, target.Margin.Top, target.Margin.Right, target.Margin.Bottom),
                To = new Thickness(160, 0, 0, 0),
                Duration = TimeSpan.FromSeconds(duration),
                FillBehavior = FillBehavior.HoldEnd,
                AccelerationRatio = .5,
                EasingFunction = be
            };

            DoubleAnimation animtion2 = new DoubleAnimation()
            {
                From = 0,
                To = 1,
                Duration = TimeSpan.FromSeconds(duration),
                FillBehavior = FillBehavior.HoldEnd,
                AccelerationRatio = .5,
                EasingFunction = be
            };

            target.BeginAnimation(ContentControl.MarginProperty, animtion);
            target.BeginAnimation(ContentControl.OpacityProperty, animtion2);
        }