Rhys Towey Rhys Towey - 1 month ago 18
C# Question

StackPanel reverse order - WPF

I am trying to reverse the order of which the children appear in the StackPanel. I want to be able to add new children (whilst running the app) to the top of the list instead of the bottom. I have tried using various XAML code but nothing worked.

What is the easiest way to do this?

Answer

Use:

stackPanel.Children.Insert(0, uiElement);

This will insert the element at the head of the list.

Source

Comments