在wpf中更改stackpanel的子级索引 [英] change the children index of stackpanel in wpf
问题描述
我想知道如何使用 c#代码来更改StackPanel的儿童索引.
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.
我正在使用StackPanel,因为我需要Orientation属性来堆叠所有元素并将它们分组在一起.如果您有更好的主意使用其他控件,则可以接受.
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.
推荐答案
StackPanel.Children 是插入和 RemoveAt 方法.
StackPanel.Children is a UIElementCollection that easily allows to reorder elements by e.g. its Insert and RemoveAt methods.
这篇关于在wpf中更改stackpanel的子级索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!