Пример #1
0
        private Size OnMeasure(Size availableSize)
        {
            var width = availableSize.Width == double.PositiveInfinity || availableSize.IsEmpty() ?
                        Width : availableSize.Width;
            var height = availableSize.Height == double.PositiveInfinity || availableSize.IsEmpty() ?
                         Height : availableSize.Height;

            // Get the set of ticks that we want to measure.  This could either be all ticks or only minor ticks
            var measuredChildren = ShowTickLabels ? Children.Cast <UIElement>() : Children.Cast <UIElement>().Where(el => !GetIsMajorTickmark(el));

#if !__IOS__
            foreach (UIElement d in measuredChildren)
            {
                d.Measure(availableSize);
            }
#endif

            if (double.IsNaN(height))
            {
                height = 0;
                foreach (UIElement d in measuredChildren)
                {
                    var maxHeight = Math.Max(GetDesiredSize(d).Height, height);
                    height =
#if __IOS__
                        (nfloat)maxHeight;
#else
                        maxHeight;
#endif
                }
            }

            width = double.IsNaN(width) ? 0 : width;

            return(new Size(width, height));
        }