Im I just misunderstanding the name "AutoSize"-property on the Editor-control or does it simply not work?
I have a control like this in xaml:
<Editor AutoSize="TextChanges" HeightRequest="100"/>
It comes out fine at height 100, but when I have written a few rows it does not change size/height. The upper text is simply scrolled up.
Cause:
An Editor will not auto-size
if the HeightRequest
property has been set.
You can refer to :
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/editor#auto-sizing-an-editor
Solution:
You can remove the HeightRequest
property.And the Editor
will automatically grows when you continue typing additional rows.
<Editor Text="Enter text here" AutoSize="TextChanges" />
In case you want AutoSize to work and at the same time to have height of 100, you can do something like this:create a new class that inherits Editor, override method below and use a new class instead on your page
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
{
var sizeRequest = base.OnMeasure(widthConstraint, heightConstraint);
return new SizeRequest(new Size(sizeRequest.Request.Width, Math.Max(100, sizeRequest.Request.Height)));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With