如何在文本框中滚动? [英] how to give scrolling in textbox?
问题描述
我拿了一个文本框
<TextBox Height="218" HorizontalAlignment="Stretch" Margin="0,56,0,0" Name="txtBox" VerticalAlignment="Top" TextWrapping="Wrap"
Text="" GotFocus="txtBox_GotFocus" TextChanged="txtBox_TextChanged" IsTabStop="True"
IsEnabled="True" IsHitTestVisible="True" VerticalScrollBarVisibility="Auto" Background="White" FontFamily="Tahoma" />
现在,当我在文本框中输入大量文本时,文本会自动向上滚动.我想显示一个滚动条,用户可以使用它浏览整个文本.如何做到这一点.
Now when i enter lot of text in textbox then text scrolled up automatically. I want to show a scrollbar with which user can surf to the whole text. How to do this.
推荐答案
这个问题没有简单的解决方案.此外,如果您允许某人输入大量文本,那么当他们添加更多行时,您可能会达到对 UIElements 施加的高度限制 (2048px).
There isn't a simple solution to this problem. Additionally, if you are allowing someone to enter a large amount of text it's possible that as they add more lines you coudl reach the height limit (2048px) imposed on UIElements.
如果您需要用户能够输入大量文本,您应该考虑将 Input
元素放在 WebBrowser
控件中,并将其用于字段.
If you need users to be able to enter a large amount of text you should consider putting an Input
element inside a WebBrowser
control and using that for the field instead.
这篇关于如何在文本框中滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!