question

JesseKnott-2239 avatar image
0 Votes"
JesseKnott-2239 asked ·

Is there a text field that will auto size it's self to the content

I need what would effectively be an Editor field that will resize it's self to the content within.

I have this code, but the problem seems that the editor field becomes oversized when large amounts of text is entered.

This is the code,

public EditorXF()
{
try
{
TextChanged += (sender, e) => InvalidateMeasure();
}
catch (Exception ex)
{
DebugTools.LogException(ex);
}
}

this code will modify the "Text Box", but like I said, if you enter large amounts of text, it will oversize it's self.
Here are some screen caps to demonstrate what I am talking about.

In the photos, I have simply highlighted the text in the "Output" and pasted it into the "Input" field

[1]: /answers/storage/attachments/77524-screenshot-1615746770.png

[2]: /answers/storage/attachments/77389-screenshot-1615746782.png

dotnet-xamarinforms-xaml
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sorry, cant seem to find the "edit" to add a detail.
It seems that the text when copied and pasted in is doubling the pasted text in length.

0 Votes 0 ·

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered ·

but the problem seems that the editor field becomes oversized when large amounts of text is entered ... It seems that the text when copied and pasted in is doubling the pasted text in length.

Hi, JesseKnott-2239. I created a basic demo to test entering text or pasting text, both work fine. The Editor class provides the AutoSize property which that controls whether the editor will change size to accommodate input as the user enters it. Try to set the property to TextChanges and test again.

<Editor AutoSize="TextChanges"/>


Tutorial: https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.editorautosizeoption?view=xamarin-forms

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.