Fix measuring empty Entry heights

This commit is contained in:
Frank A. Krueger 2017-12-10 20:23:19 -08:00
parent 9d50826c18
commit a211e8d4f8
1 changed files with 11 additions and 1 deletions

View File

@ -17,7 +17,17 @@ namespace Ooui.Forms.Renderers
public override SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint) public override SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint)
{ {
var size = Element.Text.MeasureSize (Element.FontFamily, Element.FontSize, Element.FontAttributes); var text = Element.Text;
if (text == null || text.Length == 0) {
text = Element.Placeholder;
}
Size size;
if (text == null || text.Length == 0) {
size = new Size (Element.FontSize * 0.25, Element.FontSize);
}
else {
size = text.MeasureSize (Element.FontFamily, Element.FontSize, Element.FontAttributes);
}
size = new Size (size.Width, size.Height * 1.428 + 14); size = new Size (size.Width, size.Height * 1.428 + 14);
return new SizeRequest (size, size); return new SizeRequest (size, size);
} }