I believe this is due to the use of ItemContainerGenerator.ContainerFromItem .
ListBox uses VirtualizingStackPanel by default. Thus, elements that do not appear on the screen when the window loads are not yet created. Setting them to Collapsed does not affect as soon as they return to the screen.
You can play a little by changing the initial height of the Window . If you set it to 550 or so, it works as expected. If you set 150 or so, you will have many elements that are still visible.
One thing you can do to change this, if you don't have as many items, just change the ItemsPanel .
source share