问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/44723118/uwp-application-not-reading-line-feed