private void ShrinkColumnD(bool isShrink) { GridLengthAnimation animation = new GridLengthAnimation(); if (isShrink) { animation.From = new GridLength(columnDMainLeft.ActualWidth, GridUnitType.Pixel); animation.To = new GridLength(0, GridUnitType.Pixel); } else { animation.From = new GridLength(0, GridUnitType.Pixel); animation.To = new GridLength(300, GridUnitType.Pixel); } columnDMainLeft.Width = animation.To; animation.Duration = new Duration(TimeSpan.FromSeconds(0.5)); animation.FillBehavior = FillBehavior.Stop; columnDMainLeft.BeginAnimation(ColumnDefinition.WidthProperty, animation); }