StackPanel adaptation doesn't work

I’m making a leaderboard and I need to dynamically fill it with lines with players. To do this, I put one StackPanel in the ScrollViewer. Then I put 3 more StackPanels in it, which are responsible for groups of players. The problem is that when working in the GUI Editor, the stack panel increases and displays all the elements in itself ONLY if I set “adaptWidthToChildren true”. Otherwise, when adding new rows, they are not displayed and the stack panel does not automatically expand under them.

However, I have read that this is wrong. In addition, when I myself started displaying the screen in the project, I saw that, unlike the editor, in the project it adapts only to the tallest child, and not to the sum of the heights of all children.

How to solve the problem? How to make the stack panel expand automatically when filling and display all the elements in it vertically?

when I did something similar I think I had to calculate the height/width of the elements manually and just then update the parent element.

Let me see if I can find an example.

If you see the addContent method that is the solution I ended up with for a “similar” thing.


Oh, thank you! I also thought that I would have to do it manually. I’ll try to look for more. If it doesn’t work out, I’ll use something similar.

1 Like