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);
        }
        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);
        }
Exemple #3
0
        public void ShowRow(bool bShow, bool canHide)
        {
            CanHide = canHide;
            InitialControlHeight = _container.Height;
            Action postAction = () => PostAnimationAction(_container);

            if (bShow)
            {
                if (_row.Height.Value == 0) //show
                {
                    //_row.Height = InitialRowHeight;
                    GridLengthAnimation.AnimateRow(_row, InitialRowHeight, 500, postAction);
                }
            }
            else
            {
                if (_row.Height.Value == InitialRowHeight.Value) //hide
                {
                    //_row.Height = new GridLength(0);
                    GridLengthAnimation.AnimateRow(_row, new GridLength(0), 500, postAction);
                }
            }
        }