ListView only for Text elements?

Hello, I am once again asking for your support.

I have tried to put buttons and almost blank UIElements (only set size and Text as child element) into a ListView however I am not sure if this is supposed to even work because it behaves very strange.

Basically, the whole automatic positioning and sizing does not seem to work, buttons seem to have a height of 0 (only seeing the borders) and they all stack on top of each other. The UIElements also just stack up.

Using regular Text everything works fine. I tried this by adjusting sample 48, I changed the loop which fills the ListView to this:

for (int i = 0; i < 32; i++)
    auto* button = new Button(context_);

    auto* text = new Text(context_);
    text->SetText(ToString("List item %d", i));
    text->SetName(ToString("Item %d", i));

    //button->SetStyleAuto();//setting style here doesnt change the behaviour either

Mind you that I can likely work with just Text elements, just wondering if this is working as intended or I am doing something wrong.

No, it does not just work with Text items. I created complex items with icon, 2 lines of text a custom element, and it works fine, see
This uses an UISelectable as container which is added as item to the listview.
Maybe it does not work with only Buttons (didn’t try that), so you could also use a UISelectable as container, set the layout of it and add the button to it.

I can confirm it does work with buttons (at least on C++)

root->LoadChildXML(Cache->GetResource<XMLFile>("UI/TodoList.xml")->GetRoot(), root->GetDefaultStyle());
for (int i = 0; i < 4; i++) {
		WeakPtr<Button> button;
		button = new Button(GetContext());
		button->SetFixedSize(IntVector2(75, 75));

Did you enable the automatic positioning/sizing? Try SetLayoutMode(LM_VERTICAL) and give the ListView a minimum size.

The UI system is a mess at first glance but once you learn how it works it’s way better compared to some alternatives

Thanks, those samples helped. In particular, button->SetFixedSize() did the trick.

Why does SetFixedSize work but SetSize does not?

My guess is that because the parent has zero size, any children with a non-fixed size would get overridden to zero. Check if the listview has a size set/layout too.