/// <summary> /// Calculates the new size for the Left element being expanded. /// </summary> /// <param name="totalSize"></param> /// <param name="startingPoint"></param> /// <returns></returns> private double NewSizeForExpansion(Double totalSize, Double startingPoint) { Double newSize = totalSize; if (CommonTasksExpanded) { GridLengthAnimation gla = new GridLengthAnimation(); gla.From = new GridLength(CommonTasksContentDef.ActualHeight); gla.To = new GridLength(newSize, GridUnitType.Star); gla.Duration = new Duration(new TimeSpan(1000000)); CommonTasksContentDef.BeginAnimation(RowDefinition.HeightProperty, gla); } return newSize; }
/// <summary> /// Handles the event when the Common Tasks Header is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CommonTasksExpanderBorder_MouseDown(object sender, MouseButtonEventArgs e) { if (CommonTasksExpanded) { GridLengthAnimation gla = new GridLengthAnimation(); gla.From = new GridLength(CommonTasksContentDef.ActualHeight); gla.To = new GridLength(0); gla.Duration = new Duration(new TimeSpan(1000000)); CommonTasksContentDef.BeginAnimation(RowDefinition.HeightProperty, gla); CommonTasksExpanded = false; CommonTasksExpanderBorder.CornerRadius = new CornerRadius(3, 3, 3, 3); Double newSize = LeftContentGrid.ActualHeight; newSize = NewSizeForExpansion(newSize,0); } else { Double newSize = LeftContentGrid.ActualHeight; newSize = NewSizeForExpansion(newSize,1); GridLengthAnimation gla = new GridLengthAnimation(); gla.From = new GridLength(0); gla.To = new GridLength(newSize, GridUnitType.Star); gla.Duration = new Duration(new TimeSpan(1000000)); CommonTasksContentDef.BeginAnimation(RowDefinition.HeightProperty, gla); CommonTasksExpanded = true; CommonTasksExpanderBorder.CornerRadius = new CornerRadius(3, 3, 0, 0); } }