public void AnimateButton(ColumnDefinition[] Columns, Button[] Buttons, bool Expand)
 {
     for (int i = 0; i < Columns.Length; i++)
     {
         GridLengthAnimation AnimCol = new GridLengthAnimation();
         if (Expand == false)
         {
             AnimCol.From = new GridLength(Buttons[i].Width + 10);
             AnimCol.To   = new GridLength(0);
         }
         else
         {
             AnimCol.From = new GridLength(0);
             AnimCol.To   = new GridLength(Buttons[i].Width + 10);
         }
         AnimCol.Duration = new Duration(TimeSpan.FromSeconds(0.4));
         Columns[i].BeginAnimation(ColumnDefinition.WidthProperty, AnimCol);
     }
 }
        public void AnimateRowGrid(RowDefinition Source, RowDefinition Destination, Grid GridSource, Grid GridDestination, ref GridLength PrevHeight)
        {
            AnimateRowGridGridSource   = GridSource;
            GridSource.Visibility      = System.Windows.Visibility.Visible;
            GridDestination.Visibility = System.Windows.Visibility.Visible;

            GridLengthAnimation GridAnimHiddenCol = new GridLengthAnimation();

            GridAnimHiddenCol.From     = Source.Height;
            GridAnimHiddenCol.To       = new GridLength(0);
            GridAnimHiddenCol.Duration = new Duration(TimeSpan.FromSeconds(0.3));

            GridLengthAnimation GridAnimVisibleCol = new GridLengthAnimation();

            GridAnimVisibleCol.From       = new GridLength(0);
            GridAnimVisibleCol.To         = PrevHeight;
            GridAnimVisibleCol.Duration   = new Duration(TimeSpan.FromSeconds(0.3));
            GridAnimVisibleCol.Completed += GridAnimVisibleCol_Completed;


            PrevHeight = Source.Height;
            Source.BeginAnimation(RowDefinition.HeightProperty, GridAnimHiddenCol);
            Destination.BeginAnimation(RowDefinition.HeightProperty, GridAnimVisibleCol);
        }