I have a listbox that contains expanders as its child elements. When I expand one of the child elements the listbox grows as I would hope and becomes taller. The problem I have is that when I collapse that expander, the listbox doesn't reduce
it's size back down. I need my listbox to always only use up the space occupied by its children. So I want it to grow if the children get bigger but to reduce its size when the children are again made smaller. Can I do this with xaml via
properties or a clever control template, or am I going to need to do it via code?
Here is an example of the xaml that shows what it currently does.