问题描述
我正在创建一个C#UWP应用程序,我注意到当我将其输入到文本框中时,输出文本中缺少换行符(\ n).当我按Enter进入文本框时,它会生成CR + LF字符(\ r \ n).我该怎么做才能使文本框的行为引起CR + LF和amp;如果.我已经设置了AcceptReturn ="true",我什至尝试用\ r \ n替换\ n,但这也不起作用.
正如@lindexi所说,新的TextBox
在Windows 10内部版本15063中将\r
用作换行符. CR + LF和如果.您可以在KeyUp事件中以编程方式处理它.但是\n
& \n\r
将自动变为\r
.
例如:
// original
MyTextBox.Text = "Nico Zhu \nzhuminghao\nwanglaoshi\r\n\rzhuzhuz\n";
// converted
MyTextBox.Text = "Nico Zhu \rzhuminghao\rwanglaoshi\r\rzhuzhuz\r"
有关更多信息,请参考提供意外结果的UWP TextBox控件. /p>
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.
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.
这篇关于UWP应用程序不读取换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!