Example #1
0
        private void LayoutGrid_MouseLeave(object sender, MouseEventArgs e)
        {
            storyboard.Children.Clear();

            //行高判断
            if (this.cellTop.Height != new GridLength(1, GridUnitType.Star))
            {
                GridLengthAnimation cellTopAnimation = this.FindResource("cellTopAnimation") as GridLengthAnimation;
                if (cellTopAnimation != null)
                {
                    cellTopAnimation.From = new GridLength(2, GridUnitType.Star);
                    cellTopAnimation.To   = new GridLength(1, GridUnitType.Star);
                    storyboard.Children.Add(cellTopAnimation);
                }
            }
            if (this.cellBot.Height != new GridLength(1, GridUnitType.Star))
            {
                GridLengthAnimation cellBotAnimation = this.FindResource("cellBotAnimation") as GridLengthAnimation;
                if (cellBotAnimation != null)
                {
                    cellBotAnimation.From = new GridLength(2, GridUnitType.Star);
                    cellBotAnimation.To   = new GridLength(1, GridUnitType.Star);
                    storyboard.Children.Add(cellBotAnimation);
                }
            }
            //列宽判断
            if (this.cellLeft.Width != new GridLength(1, GridUnitType.Star))
            {
                GridLengthAnimation cellLeftAnimation = this.FindResource("cellLeftAnimation") as GridLengthAnimation;
                if (cellLeftAnimation != null)
                {
                    cellLeftAnimation.From = new GridLength(2, GridUnitType.Star);
                    cellLeftAnimation.To   = new GridLength(1, GridUnitType.Star);
                    storyboard.Children.Add(cellLeftAnimation);
                }
            }
            if (this.cellRight.Width != new GridLength(1, GridUnitType.Star))
            {
                GridLengthAnimation cellRightAnimation = this.FindResource("cellRightAnimation") as GridLengthAnimation;
                if (cellRightAnimation != null)
                {
                    cellRightAnimation.From = new GridLength(2, GridUnitType.Star);
                    cellRightAnimation.To   = new GridLength(1, GridUnitType.Star);
                    storyboard.Children.Add(cellRightAnimation);
                }
            }

            storyboard.Begin(this);
        }
Example #2
0
        private void Grid01_MouseEnter(object sender, MouseEventArgs e)
        {
            storyboard.Children.Clear();

            //将上侧行高扩大为2*,同时将下侧行高缩小至1*
            if (this.cellTop.Height != new GridLength(2, GridUnitType.Star))
            {
                GridLengthAnimation cellTopAnimation = this.FindResource("cellTopAnimation") as GridLengthAnimation;
                if (cellTopAnimation != null)
                {
                    cellTopAnimation.To = new GridLength(2, GridUnitType.Star);
                    storyboard.Children.Add(cellTopAnimation);
                    GridLengthAnimation cellBotAnimation = this.FindResource("cellBotAnimation") as GridLengthAnimation;
                    if (cellBotAnimation != null)
                    {
                        cellBotAnimation.To = new GridLength(1, GridUnitType.Star);
                        storyboard.Children.Add(cellBotAnimation);
                    }
                }
            }
            //将右侧列宽扩大为2*,同时将左侧列宽缩小至1*
            if (this.cellRight.Width != new GridLength(2, GridUnitType.Star))
            {
                GridLengthAnimation cellRightAnimation = this.FindResource("cellRightAnimation") as GridLengthAnimation;
                if (cellRightAnimation != null)
                {
                    cellRightAnimation.To = new GridLength(2, GridUnitType.Star);
                    storyboard.Children.Add(cellRightAnimation);
                    GridLengthAnimation cellLeftAnimation = this.FindResource("cellLeftAnimation") as GridLengthAnimation;
                    if (cellLeftAnimation != null)
                    {
                        cellLeftAnimation.To = new GridLength(1, GridUnitType.Star);
                        storyboard.Children.Add(cellLeftAnimation);
                    }
                }
            }

            storyboard.Begin(this);
        }