后台设置控件高度为自动

panel.Height = double.NaN;
panel.Width = double.NaN;

原文地址:https://www.cnblogs.com/MarcLiu/p/3722840.html