The problem is in my app the Content is dynamic and each element have different Height, so I don’t know the exact Height in pixels.
In this example if I toggle the animation only shows 5 Text elements of the 8.
How can I solve this? To toggle and animate between 0% and 100% Height of any element (Show and Collapse with animation)?
the main challenge in your snippet is that you’re tying to set something to a 100% height of undefined. Well, that is still going to be undefined, no matter how hard you try.
A vertical StackPanel does not have a set height and can not have one, because it’s meant to accommodate vertically as much items as necessary. So you can’t do it that way.
What you can do is the opposite - you can set the height of the content as high as it needs to be. Here’s a snippet of one approach you could take. Note how it makes use of the LayoutRole property coupled with a LayoutAnimation, effectively making a neat structure that interacts with itself and by pushing neighbouring elements up and down.