コード例 #1
0
        static private Size GetPreferredControlSize(IArrangedElement child, Size proposed)
        {
            var preferredsize = child.GetPreferredSize(proposed);
            int width, height;

            if (child.GetAutoSizeMode() == AutoSizeMode.GrowAndShrink)
            {
                width  = preferredsize.Width;
                height = preferredsize.Height;
            }
            else
            {
                width  = child.ExplicitBounds.Width;
                height = child.ExplicitBounds.Height;
                if (preferredsize.Width > width)
                {
                    width = preferredsize.Width;
                }
                if (preferredsize.Height > height)
                {
                    height = preferredsize.Height;
                }
            }
            return(new Size(width, height));
        }