Windows Presentation Foundation<!---->
如何:创建多行 TextBox 控件<!---->
<!-- Content type: Devdiv1. Transform: orcas2mtps.xslt. -->
更新:2007 年 11 月
本示例演示如何使用可扩展应用程序标记语言 (XAML) 定义一个 TextBox 控件,该控件将自动扩展以容纳多行文本。
<!-- ApplyClick with current id -->
示例
示例
<!---->
将 TextWrapping 属性设置为 Wrap 会导致输入的文本在到达 TextBox 控件的边缘时换至新行,必要时会自动扩展 TextBox 控件以便为新行留出空间。
将 AcceptsReturn 属性设置为 true 会导致在按 Return 键时插入新行,必要时会再次自动扩展 TextBox 以便为新行留出空间。
VerticalScrollBarVisibility 属性向 TextBox 添加一个滚动条,以便在 TextBox 超出包含它的框架或窗口的大小时,可以滚动 TextBox 的内容。
C#
<TextBox Name="tbMultiLine" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" > This TextBox will allow the user to enter multiple lines of text. When the RETURN key is pressed, or when typed text reaches the edge of the text box, a new line is automatically inserted. </TextBox>
本文介绍如何使用XAML定义一个多行TextBox控件,通过设置TextWrapping为Wrap实现自动换行,AcceptsReturn为True允许按Enter键换行,并通过VerticalScrollBarVisibility添加垂直滚动条。
6519

被折叠的 条评论
为什么被折叠?



