GridLengthAnimation CreateAnimation(BaseLayoutItem item, DependencyProperty property, GridLength value) { GridLength to = new GridLength(0, GridUnitType.Star); if (maximizedItem != null) { if (maximizedItem == item || maximizedItem.Parent == item) { to = value; } } else { to = value; } GridLengthAnimation a = new GridLengthAnimation { From = (GridLength)item.GetValue(property), To = to, Duration = new TimeSpan(0, 0, 0, 0, 500), FillBehavior = System.Windows.Media.Animation.FillBehavior.Stop }; return(a); }