Example #1
0
        public override Size MeasureItem(int index, int widthConstraint, int heightConstraint)
        {
            if (widthConstraint > heightConstraint)
            {
                widthConstraint = int.MaxValue;
            }
            if (heightConstraint > widthConstraint)
            {
                heightConstraint = int.MaxValue;
            }

            var item = this[index];

            if (item != null && _dataBindedViewTable.TryGetValue(item, out View? createdView) && createdView != null)
            {
                return(createdView.Measure(DPExtensions.ConvertToScaledDP(widthConstraint), DPExtensions.ConvertToScaledDP(heightConstraint), MeasureFlags.IncludeMargins).Request.ToEFLPixel());
            }

            View?view = null;

            if (ItemTemplate is DataTemplateSelector selector)
            {
                view = selector.SelectTemplate(this[index], Element).CreateContent() as View;
            }
            else
            {
                view = ItemTemplate.CreateContent() as View;
            }

            if (view != null)
            {
                view.Parent = Element;
                if (Count > index)
                {
                    view.BindingContext = this[index];
                }
                var request = view.Measure(DPExtensions.ConvertToScaledDP(widthConstraint), DPExtensions.ConvertToScaledDP(heightConstraint), MeasureFlags.IncludeMargins).Request;
                return(request.ToEFLPixel());
            }
            return(new Size(0, 0));
        }
Example #2
0
 public override Size MeasureHeader(int widthConstraint, int heightConstraint)
 {
     return(_headerCache?.Measure(DPExtensions.ConvertToScaledDP(widthConstraint), DPExtensions.ConvertToScaledDP(heightConstraint)).Request.ToEFLPixel() ?? new Size(0, 0));
 }
Example #3
0
 public override Size MeasureFooter(int widthConstraint, int heightConstraint)
 {
     return(_footerCache?.Measure(DPExtensions.ConvertToScaledDP(widthConstraint), double.PositiveInfinity).Request.ToEFLPixel() ?? new Size(0, 0));
 }