WPF 文本框的多行 [英] Multiline for WPF TextBox
问题描述
我正在开发一个用于发送反馈的应用程序.
I am developing an app for sending some feedback.
基本上我正在尝试制作一个 TextBox
用于注释,但我已经习惯了 WinForms MultiLine=true
.我已将 MinLines
设置为 3,它正在到达那里,但如果用户能够在此块中的任何位置键入,我最好喜欢它 - 例如按 Enter 并执行点点之类的事情.例如:
Basically I'm trying to make a TextBox
for comments, but I'm used to the WinForms MultiLine=true
. I've set MinLines
to 3, which is getting there, but preferably I'd like it if the user is able to type wherever in this block - like press enter and do dot points sort of thing. For example:
- Item 1 blah
- Item 2 blahlb lahbvl d
但此刻文本都停留在一行上.
But at the moment the text all stays on one line.
- Item 1 blah - Item 2 blahb blahb blah
这些评论将有助于填写已发送电子邮件的正文.如果在将此字符串放入电子邮件正文字符串时无法轻松保持相同的格式(这样发送时的格式与键入时的格式相同),那可能毫无意义.
These comments will then help fill the body of an email which is sent. It may be pointless if I can't easily keep the same formatting when putting this string into the email body string (so that it looks like it does when sent as it does when typed).
我可以实现我所追求的,还是必须将其作为所有文本保留在一行中?
Can I achieve what I'm after or do I have to leave it as all text on one line?
推荐答案
在您的 TextBox 上启用 TextWrapping="Wrap"
和 AcceptsReturn="True"
.
Enable TextWrapping="Wrap"
and AcceptsReturn="True"
on your TextBox.
您可能还希望启用 AcceptsTab
和 SpellCheck.IsEnabled
.
You might also wish to enable AcceptsTab
and SpellCheck.IsEnabled
too.
这篇关于WPF 文本框的多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!