public virtual SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { var s = TypedNativeView.SizeThatFits(new CoreGraphics.CGSize((float)widthConstraint, (float)heightConstraint)); var request = new Size(s.Width == float.PositiveInfinity ? double.PositiveInfinity : s.Width, s.Height == float.PositiveInfinity ? double.PositiveInfinity : s.Height); return(new SizeRequest(request)); }
public virtual Size GetDesiredSize(double widthConstraint, double heightConstraint) { var sizeThatFits = TypedNativeView?.SizeThatFits(new CoreGraphics.CGSize((float)widthConstraint, (float)heightConstraint)); if (sizeThatFits.HasValue) { return(new Size( sizeThatFits.Value.Width == float.PositiveInfinity ? double.PositiveInfinity : sizeThatFits.Value.Width, sizeThatFits.Value.Height == float.PositiveInfinity ? double.PositiveInfinity : sizeThatFits.Value.Height)); } return(new Size(widthConstraint, heightConstraint)); }
public virtual Size GetDesiredSize(double widthConstraint, double heightConstraint) { if (TypedNativeView == null) { return(new Size(widthConstraint, heightConstraint)); } var sizeThatFits = TypedNativeView.SizeThatFits(new CoreGraphics.CGSize((float)widthConstraint, (float)heightConstraint)); var size = new Size( sizeThatFits.Width == float.PositiveInfinity ? double.PositiveInfinity : sizeThatFits.Width, sizeThatFits.Height == float.PositiveInfinity ? double.PositiveInfinity : sizeThatFits.Height); if (double.IsInfinity(size.Width) || double.IsInfinity(size.Height)) { TypedNativeView.SizeToFit(); size = new Size(TypedNativeView.Frame.Width, TypedNativeView.Frame.Height); } return(size); }