childWidthMeasureSpec = new MeasureSpecification( new LayoutLength(childLength), MeasureSpecification.ModeType.Exactly );
childHeightMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(
- new LayoutLength(heightMeasureSpec.Size - (Padding.Top + Padding.Bottom + childLayout.Owner.Margin.Top + childLayout.Owner.Margin.Bottom)),
+ new LayoutLength(heightMeasureSpec.Size - (childLayout.Owner.Margin.Top + childLayout.Owner.Margin.Bottom)),
heightMeasureSpec.Mode),
new LayoutLength(Padding.Top + Padding.Bottom),
new LayoutLength(desiredHeight));
{
childWidthMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(
- new LayoutLength(widthMeasureSpec.Size - (Padding.Start + Padding.End + childLayout.Owner.Margin.Start + childLayout.Owner.Margin.End)),
+ new LayoutLength(widthMeasureSpec.Size - (childLayout.Owner.Margin.Start + childLayout.Owner.Margin.End)),
widthMeasureSpec.Mode),
new LayoutLength(Padding.Start + Padding.End),
new LayoutLength(desiredWidth));
// Weighted children are not measured at this phase.
// Available space for weighted children will be calculated in the phase 2 based on totalLength value.
// Max height of children is stored.
- foreach( LayoutItem childLayout in LayoutChildren )
+ for (int i = 0; i < LayoutChildren.Count; i++)
{
+ LayoutItem childLayout = LayoutChildren[i];
int childDesiredHeight = childLayout.Owner.HeightSpecification;
float childWeight = childLayout.Owner.Weight;
Extents childMargin = childLayout.Margin;
// optimal width.
MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(
- new LayoutLength(widthMeasureSpec.Size - (Padding.Start + Padding.End + childLayout.Margin.Start + childLayout.Margin.End)),
+ new LayoutLength(widthMeasureSpec.Size - (childLayout.Margin.Start + childLayout.Margin.End)),
widthMeasureSpec.Mode),
new LayoutLength(Padding.Start + Padding.End),
new LayoutLength(LayoutParamPolicies.WrapContent));
MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(
- new LayoutLength(heightMeasureSpec.Size - (Padding.Top + Padding.Bottom + childLayout.Margin.Top + childLayout.Margin.Bottom)),
+ new LayoutLength(heightMeasureSpec.Size - (childLayout.Margin.Top + childLayout.Margin.Bottom)),
heightMeasureSpec.Mode),
new LayoutLength(Padding.Top + Padding.Bottom),
new LayoutLength(childDesiredHeight));
}
else
{
- MeasureChild(childLayout, widthMeasureSpec, heightMeasureSpec);
+ MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
}
LayoutLength childWidth = childLayout.MeasuredWidth.Size;
}
else
{
- _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + CellPadding.Width);
+ _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + (i < LayoutChildren.Count - 1 ? CellPadding.Width : 0));
}
}
// to accumulate total used space in _totalLength.
// Weighted children are not measured in this phase.
// Available space for weighted children will be calculated in the phase 2 based on _totalLength value.
- foreach( LayoutItem childLayout in LayoutChildren )
+ for (int i = 0; i < LayoutChildren.Count; i++)
{
+ LayoutItem childLayout = LayoutChildren[i];
int childDesiredWidth = childLayout.Owner.WidthSpecification;
float childWeight = childLayout.Owner.Weight;
Extents childMargin = childLayout.Margin;
// We'll restore the original height of 0 after measurement.
MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(
- new LayoutLength(widthMeasureSpec.Size - (Padding.Start + Padding.End + childLayout.Margin.Start + childLayout.Margin.End)),
+ new LayoutLength(widthMeasureSpec.Size - (childLayout.Margin.Start + childLayout.Margin.End)),
widthMeasureSpec.Mode),
new LayoutLength(Padding.Start + Padding.End),
new LayoutLength(childDesiredWidth));
MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(
- new LayoutLength(heightMeasureSpec.Size - (Padding.Top + Padding.Bottom + childLayout.Margin.Top + childLayout.Margin.Bottom)),
+ new LayoutLength(heightMeasureSpec.Size - (childLayout.Margin.Top + childLayout.Margin.Bottom)),
heightMeasureSpec.Mode),
new LayoutLength(Padding.Top + Padding.Bottom),
new LayoutLength(LayoutParamPolicies.WrapContent));
}
else
{
- MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
+ MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
}
LayoutLength childHeight = childLayout.MeasuredHeight.Size;
}
else
{
- _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + CellPadding.Height);
+ _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + (i < LayoutChildren.Count - 1 ? CellPadding.Height : 0));
}
}
}
childLeft += childMargin.Start;
childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
- childLeft += childWidth + childMargin.End + CellPadding.Width;
+ childLeft += childWidth + childMargin.End + ((i < count - 1) ? CellPadding.Width : 0);
}
}
} // LayoutHorizontally
}
}
childLayout.Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
- childTop += childHeight + childMargin.Bottom + CellPadding.Height;
+ childTop += childHeight + childMargin.Bottom + ((i < count - 1) ? CellPadding.Height : 0);
}
}
} // LayoutVertical