Undefined is - ok i don’t have any constrain use the max value you want,: MeasureMode AtMost - says take this constrain (parent size), measure yourself on it and try to be the min size you want , and MeasureMode.Exact is ok please use the size i gave to you .. for example in Stretch mode ..
void HandleSelfSizingDelegate(Xamarin.Flex.Item item, ref float width, ref float height)
{
var widthMode = FlexMeasureMode.Undefined;
var heightMode = FlexMeasureMode.Undefined;
var availableWidth = item.Parent.Width;
var availableHeight = item.Parent.Height;
var size = _measure?.Invoke(item as IFlexNode, availableWidth, widthMode, availableHeight, heightMode);
width = (float)size.Value.Width;
height = (float)size.Value.Height;
}
Here's my code on the Xamarin.Forms side of things
Size MeasureView(IFlexNode node, float width, FlexMeasureMode widthMode, float height, FlexMeasureMode heightMode)
{
var constrainedWidth = (widthMode == FlexMeasureMode.Undefined) ? float.MaxValue : width;
var constrainedHeight = (heightMode == FlexMeasureMode.Undefined) ? float.MaxValue : height;
View view = node.Data as View;
var sizeRequest = view.Measure(constrainedWidth, constrainedHeight);
var sizeThatFitsWidth = (float)sizeRequest.Request.Width;
var sizeThatFitsHeight = (float)sizeRequest.Request.Height;
var finalWidth = SanitizeMeasurement(constrainedWidth, sizeThatFitsWidth, widthMode);
var finalHeight = SanitizeMeasurement(constrainedHeight, sizeThatFitsHeight, heightMode);
return new Size(finalWidth, finalHeight);
}
static float SanitizeMeasurement(float constrainedSize, float measuredSize, FlexMeasureMode measureMode)
{
float result;
if (measureMode == FlexMeasureMode.Exactly)
{
result = constrainedSize;
}
else if (measureMode == FlexMeasureMode.AtMost)
{
result = Math.Min(constrainedSize, measuredSize);
}
else
{
result = measuredSize;
}
return result;
}
What i m missing is a MeasureMode,
Undefined is - ok i don’t have any constrain use the max value you want,: MeasureMode AtMost - says take this constrain (parent size), measure yourself on it and try to be the min size you want , and MeasureMode.Exact is ok please use the size i gave to you .. for example in Stretch mode ..
Here's my code on the Xamarin.Forms side of things