加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

xaml – 如何使用MultiLine和Scroller进行WinRT TextBox

发布时间:2020-12-14 03:53:44 所属栏目:Windows 来源:网络整理
导读:我正在使用 Windows应用商店应用并尝试使用多行和滚动条创建一个文本框. 我假设这应该像在WPF中一样容易实现. 我怎样才能做到这一点?非常感谢!! 解决方法 我会在这里回答,因为我无法在评论中添加图片.正如我所建议的那样,看看模板.在网格模板中(在网格和
我正在使用 Windows应用商店应用并尝试使用多行和滚动条创建一个文本框.

我假设这应该像在WPF中一样容易实现.

我怎样才能做到这一点?非常感谢!!

解决方法

我会在这里回答,因为我无法在评论中添加图片.正如我所建议的那样,看看模板.在网格模板中(在网格和拆分模板中),RichTextColumns.cs应该提供一些灵感.

您可以看到RichEditBox控件的简单使用,或/和更多“高级”场景的组合,即多列. RichEditBox可以在XAML工具包中找到所有Windows STore应用程序,该列只是两个模板中的示例实现.

如果您只想要多行和滚动,只需使用RichEditBox控件即可.将textwrapping设置为wrap,并将AcceptsReturn属性设置为true.如果你愿意,可以将它包装成卷轴,但要记住我所说的关于水平和垂直滚动的内容.

如果您查看控件的文档,您甚至可以找到一个示例.如果您想要其他内容,请在上面提供更多信息,但请务必先进行研究.

From MSDN documentation: (and I recommend you read this and the guidelines)

Choosing the right multi-line text input control When users need to
enter or edit long strings,use a multi-line text control. There are
two types of multi-line text input control.

For plain text,use a TextBox control. Set the AcceptsReturn property
to true and set the TextWrapping property to TextWrapping.Wrap.

For formatted text,hyperlinks,inline images,and other rich content,
use the RichEditBox control. Set the AcceptsReturn property to true
and set the TextWrapping property to TextWrapping.Wrap. If the primary
purpose of the multi-line text box is for creating documents (such as
blog entries or the contents of an email message),and those documents
require rich text,use a RichEditBox control. If you want users to be
able to format their text,use a RichEditBox control. When capturing
text that will only be consumed,and not redisplayed at a later time
to users,use a TextBox control. For example,suppose you have a
survey; the user completes the survey and the data is sent to some
server,but the user doesn’t ever see it again. It is generally
unnecessary to allow users to style this text.

For all other scenarios,use a TextBox control whenever possible.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读