We had the same problem with Panels vertically below each other.
Each has optional items that might be hidden and the wrapper should shrink. This code solved it as suggested by Svetoslav:
var panels =
detail.Height = Unit.Pixel(1);
(var i = 0; i < panels.Count; i++)
panels[i].Height = Unit.Pixel(0);
(i > 0)
PointU(Unit.Pixel(0), panels[i - 1].Location.Y.Add(panels[i - 1].Height));