Search code examples
wpfanimationstackpanel

How animate insert/delete items in StackPanel


I want to animate insert\delete the item in a StackPanel.
Eg: If new item inserted into collection all other items smoothly free space for new item and vice versa.

Can anyone suggest examples or ideas on this topic?


Solution

  • I would animate the Height of objects

    If adding, I would add items with a Height of 0 and animate it full size

    If deleting, I would animate the height to 0 and remove the item when the height hits 0

    This should work for most single-line items, although if your items contain multiple controls that are designed to stretch and fit whatever space is available to them, you might have to find another solution.