예제 #1
0
        public override SizeF MeasureOverride(SizeF availableSize)
        {
            if (this.Visibility == Visibility.Collapsed)
            {
                this.measuredFor = availableSize;
                return(this.measuredSize = SizeF.Empty);
            }

            // TODO: size caching

            this.measuredFor = availableSize;
            availableSize    = new SizeF(
                MathF.Max(0, availableSize.Width - Margin.HorizontalThicknessF()),
                MathF.Max(0, availableSize.Height - Margin.VerticalThicknessF()));

            if (!double.IsNaN(this.Height))
            {
                availableSize.Height = (nfloat)this.Height;
            }

            if (!double.IsNaN(this.Width))
            {
                availableSize.Width = (nfloat)this.Width;
            }

            this.measuredSize = this.panel.MeasureOverride(this.SizeThatFitsMaxAndMin(availableSize));

            this.measuredSize.Width  += this.Margin.HorizontalThicknessF();
            this.measuredSize.Height += this.Margin.VerticalThicknessF();

            return(this.measuredSize);
        }