I want the editor in my Xamarin forms project to add "/n" each line it wraps in the editor. The only way it adds it now is if i press enter.
How can I access this?
Inherit a new control from Editor. ResizingEditor : Editor
or some such.
Subscribe to .TextChanged
event.
On any text changed call InvalidateMeasure()
It will update itself when any text changes, not just for wrapping. Thus also handle when a big block is deleted etc. Most time that change won't seem like anything unless it so happens that it has gotten long enough to need more space.
Answers
Why would you want that? It defies decades of normal behavior for "word wrap". It would make the text specific to the particulars of that device... Font size, screen size, user accessibility screen magnification setting...
Do you really
want to see test disp-
layed like this if
it gets openeed on
a different device than
the one that created
it?
Or even just from the
screen rotating from
portrait to land-
scape?
Forget i even mentioned adding "/n". Better Question: Is there a "OnLineWrap" sort of event when the editor wraps a line?> @ClintStLaurent said:
Still sounds like your trying to micro-manage the text. What is it you are trying to accomplish? What is the end goal of all this?
Thinking about such an event. If you had 12k of text in an editor... and you rotate from landscape to portrait... I'm guessing about 250,000 events would trigger as all that text re-wrapped - give or take the nature of the text and if you're on a phone versus tablet - etc. Is that really something you think you need to take on?
Im trying to auto resize the editor when a new line of text is added to the editor. Like in the ios messanger app. It resizes when i press enter and create a new line, but does nothing when the text reaches the end of the editor. If I had a way to notify when the text reaches the end, I could pop in a "/n". Any other solutions?
Inherit a new control from Editor.
ResizingEditor : Editor
or some such.Subscribe to
.TextChanged
event.On any text changed call
InvalidateMeasure()
It will update itself when any text changes, not just for wrapping. Thus also handle when a big block is deleted etc. Most time that change won't seem like anything unless it so happens that it has gotten long enough to need more space.
That worked perfectly, thank you!