change the children index of stackpanel in wpf

c#, controls, stackpanel, wpf

Solution

StackPanel.Children is a UIElementCollection that easily allows to reorder elements by e.g. its Insert and RemoveAt methods.

Problem

I want to know how I can change the children index of a StackPanel in c# code. For example, I want to make the child that is currently second to be displayed first. I need animation when changing the index. I am using a StackPanel because I need the Orientation property to stack all elements and keep them grouped together. If you have better idea to use another control, I am open to that.

Original source