I am creating a C# UWP application and I have noticed that the line feed (\n) character is missing from the output text when I enter it into a Textbox. When I press enter into my Textbox it produces CR+LF character (\r\n). what can I do to bring the textbox behavior to notice both CR+LF & LF. I have set AcceptReturn = "true" and I have even tried replacing \n with \r\n but that doesn't work either.
Asked
Active
Viewed 300 times
0
-
1Your question is not clear. what does it mean to have the textbox notice LF? how will you get LF into the textbox? if you press Enter you will always get a CRLF – jayongg Jun 23 '17 at 14:55
-
I want my textbox to get LF not just CRLF. Is there a way I can do that? – Stavros Jun 23 '17 at 15:49
-
New textBox use `\r` – lindexi Jun 24 '17 at 05:00
1 Answers
0
As @lindexi said the new TextBox
used \r
as line feed character in Windows 10 build 15063. If you want to bring the textbox behavior to notice both CR+LF & LF. You may handle it programmatically on KeyUp event. However the \n
& \n\r
will turn to \r
automatically.
For example :
// original
MyTextBox.Text = "Nico Zhu \nzhuminghao\nwanglaoshi\r\n\rzhuzhuz\n";
// converted
MyTextBox.Text = "Nico Zhu \rzhuminghao\rwanglaoshi\r\rzhuzhuz\r"
For more please refer to UWP TextBox control giving unexpected results.

Nico Zhu
- 32,367
- 2
- 15
- 36
-
Do you think if I reinstall an earlier form of windows, like Windows 8, that it will make my TextBox use \n and \r as line feed characters rather than just \r. Because I need the application to be able to read the \n character as line feed character. however as it stands now, the \n is being filtered out of my TextBox as it gets typed in. – Stavros Jun 26 '17 at 13:23
-
This is super inconvenient: now the text entered in my UWP app looks different in my Xamarin iOS and Android app depending on the Windows version it was entered in, how on earth will I fix this... – Niels Dec 12 '18 at 15:37