Пример #1
0
        /// <summary>
        /// Applies the framework element constraints like the size and max size, using the provided measured size.
        /// </summary>
        /// <param name="view"></param>
        public static void OnMeasureOverride <T>(T view, _Size measuredSize)
            where T : View, IFrameworkElement
        {
            var updated = IFrameworkElementHelper
                          .SizeThatFits(view, new _Size(measuredSize.Width, measuredSize.Height).PhysicalToLogicalPixels())
                          .LogicalToPhysicalPixels();

            Windows.UI.Xaml.Controls.Layouter.SetMeasuredDimensions(view, (int)updated.Width, (int)updated.Height);
        }
Пример #2
0
        private CGSize?XamlMeasure(CGSize availableSize)
        {
            // If set layout has not been called, we can
            // return a previously cached result for the same available size.
            if (
                !RequiresMeasure &&
                _lastAvailableSize.HasValue &&
                availableSize == _lastAvailableSize
                )
            {
                return(_lastMeasure);
            }

            _lastAvailableSize = availableSize;
            RequiresMeasure    = false;

            var result = _layouter.Measure(SizeFromUISize(availableSize));

            result = IFrameworkElementHelper
                     .SizeThatFits(this, result)
                     .ToFoundationSize();

            return(result.LogicalToPhysicalPixels());
        }