文本框中的换行符
如何在 WP7 中的 TextBox 中获得换行符?我正在开发基于社交的应用程序(如 facebook),如果我设置 AcceptReturn=true,它会给我一个视觉(ui)换行符,但是当我将此文本发送到服务器时,我可以看到没有换行符。请帮我解决这个问题。我尝试过
void whatsend_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
if (e.Key == Key.Enter) {
whatsend.Text +="\r";//or /n,
}
}
但没有成功。
How can I get a linebreak in TextBox in WP7? I'm developing social-based app(like facebook) and if I set AcceptReturn=true, it gives me a visual(ui) linebreak, but when I send this text to the server I can see that there is no linebreak. Please help me with this problem. I've tried
void whatsend_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
if (e.Key == Key.Enter) {
whatsend.Text +="\r";//or /n,
}
}
but with no success.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Windows 使用
\r\n
来换行,而不是\r
,但这无关紧要;请改用Environment.NewLine。另外,根据文档:
您是否将
MultiLine
设置为true
?编辑:啊哈,WP7... 这是一篇文章我发现尝试在WP7中创建多行文本框。
Windows uses
\r\n
for line breaks, not\r
, but that's irrelevant; useEnvironment.NewLine
instead.Also, per the docs:
Did you set
MultiLine
totrue
?EDIT: Ahhh, WP7... here is an article I found which attempts to create a multi-line textbox in WP7.
Environment.NewLine 如果与正常开发相同。
Environment.NewLine if its the same as normal development.
只需将以下范围添加到 xaml 代码中:
如下所示:
just add below scope to xaml code:
something like this:
我对 WP7 不熟悉,但 Windows 通常使用“
\r\n
”(即两个字符一个接一个)来表示换行符。如果您将两者都附加到文本中,它可以解决您的问题吗?
话虽如此,我很惊讶键入的换行符被从文本框中删除。当您说文本在服务器上不可见时,您的意思是什么?文本是否没有发送到和/或记录在服务器上,或者您在服务器上的显示方法没有显示它?
I'm not familiar with WP7 but Windows in general uses "
\r\n
" (i.e. both chars one after the other) to signify a line break.If you append both to your text, does it solve your problem?
Having said that, I'm surprised that typed line breaks are being removed from the textbox. When you say the text isn't viewable on the server, what do you mean? Is it that the text isn't sent to and / or recorded on the server or that your method of display on the server isn't showing it?