UWP application not reading line feed

杀马特。学长 韩版系。学妹 提交于 2019-12-25 09:20:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!