Esempio n. 1
0
 public void SidePanel_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Expanded")
     {
         if ((sender as SidePanel).Expanded)
         {
             AnimationHelper.AnimateGridColumnExpandCollapse(SidePanelColumn, true, 300, 0, 200, new TimeSpan(0, 0, 0, 0, 200));
             SidePanelSeperatorColumn.Width = new GridLength(5);
         }
         else
         {
             AnimationHelper.AnimateGridColumnExpandCollapse(SidePanelColumn, false, 300, 0, 0, new TimeSpan(0, 0, 0, 0, 200));
             SidePanelSeperatorColumn.Width = new GridLength(0);
         }
     }
 }
        /// <summary>
        /// Called when the attached <c>IsExpanded</c> property changed.
        /// </summary>
        private static void OnIsExpandedChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            var duration      = GetDuration(dependencyObject);
            var rowDefinition = dependencyObject as RowDefinition;

            if (rowDefinition != null)
            {
                // The IsExpanded attached property of a RowDefinition changed
                if ((bool)e.NewValue)
                {
                    var expandedHeight = GetGridCellSize(rowDefinition);
                    if (expandedHeight > 0)
                    {
                        // Animate row height back to saved expanded height.
                        AnimationHelper.AnimateGridRowExpandCollapse(rowDefinition, true, expandedHeight, rowDefinition.ActualHeight, 0, duration);
                    }
                }
                else
                {
                    // Save expanded height and animate row height down to zero.
                    SetGridCellSize(rowDefinition, rowDefinition.ActualHeight);
                    AnimationHelper.AnimateGridRowExpandCollapse(rowDefinition, false, rowDefinition.ActualHeight, 0, 0, duration);
                }
            }

            var columnDefinition = dependencyObject as ColumnDefinition;

            if (columnDefinition != null)
            {
                // The IsExpanded attached property of a ColumnDefinition changed
                if ((bool)e.NewValue)
                {
                    var expandedWidth = GetGridCellSize(columnDefinition);
                    if (expandedWidth > 0)
                    {
                        // Animate column width back to saved expanded width.
                        AnimationHelper.AnimateGridColumnExpandCollapse(columnDefinition, true, expandedWidth, columnDefinition.ActualWidth, 0, duration);
                    }
                }
                else
                {
                    // Save expanded width and animate column width down to zero.
                    SetGridCellSize(columnDefinition, columnDefinition.ActualWidth);
                    AnimationHelper.AnimateGridColumnExpandCollapse(columnDefinition, false, columnDefinition.ActualWidth, 0, 0, duration);
                }
            }
        }