In the program, when you press the corresponding button, the column is hidden, when pressed again, it is revealed. Before hiding / disclosing with the help of GridSplitter, you can safely change the width of the column, the contents (Border, embedded grid in it, etc.) are also stretched or compressed. However, after performing the animation, GridSplitter stretches and compresses the column, but the contents do not change the size. Tell me, how can I fix this?

Column expansion function code:

DoubleAnimation animation = new DoubleAnimation(); animation.From = 0; MainPanel.MinWidth = 250; animation.To = MainPanel.MinWidth; animation.Duration = TimeSpan.FromSeconds(0.2); animation.Completed += Animation_Completed; RootMenu.BeginAnimation(Border.WidthProperty, animation); 

Column hiding code:

 DoubleAnimation animation = new DoubleAnimation(); animation.From = MainPanel.ActualWidth; animation.To = 0; animation.Duration = TimeSpan.FromSeconds(0.2); MainPanel.MinWidth = 0; MainPanel.Width = GridLength.Auto; RootMenu.BeginAnimation(Border.WidthProperty, animation); 

MainPanel - the name of the column RootMenu - the name of the Border.

What and where needs to be corrected so that after the animation action the GridSplitter works correctly?

There is an assumption that after the animation Border has a fixed width and therefore it does not expand. How to fix it, I can not understand

    1 answer 1

    Solution to the problem

    The problem is solved by removing the animation object when it is completed, by handling the Completed event of the animation object.