Esempio n. 1
0
        public static void AnimateRow(RowDefinition row, GridLength from, GridLength to, double duration = 500, Action postAction = null)
        {
            var animation = new GridLengthAnimation();

            animation.Duration = TimeSpan.FromMilliseconds(duration);

            animation.From = from;
            animation.To   = to;

            //https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/easing-functions
            var ef = new CubicEase();

            ef.EasingMode            = EasingMode.EaseOut;
            animation.EasingFunction = ef;

            animation.FillBehavior = FillBehavior.Stop;
            //row.Height = animation.To;

            animation.Completed += (s, e) =>
            {
                row.Height = to;
                if (postAction != null)
                {
                    postAction();
                }
            };

            row.BeginAnimation(RowDefinition.HeightProperty, animation);
        }
Esempio n. 2
0
        public static void AnimateColumn(ColumnDefinition col, GridLength to, Action postAction = null)
        {
            var da = new GridLengthAnimation();

            da.Duration = TimeSpan.FromMilliseconds(300);

            da.From = col.Width;
            da.To   = to;

            //var ef = new BounceEase();
            //ef.EasingMode = EasingMode.EaseOut;
            //da.EasingFunction = ef;

            da.FillBehavior = FillBehavior.Stop;
            //col.Width = da.To;

            da.Completed += (s, e) =>
            {
                if (postAction != null)
                {
                    postAction();
                }
                else
                {
                    col.Width = to;
                }
            };

            col.BeginAnimation(ColumnDefinition.WidthProperty, da);
        }