简体   繁体   English

WPF文本框“常规”文本输入

[英]WPF Textbox “normal” text input

G'day, G'day,

I'm not sure if this is a problem relevant to only me or if anyone else has this issue also. 我不确定这是仅与我有关的问题,还是其他人也有此问题。 None the less, I'll try and describe what is going on here. 尽管如此,我将尝试描述此处发生的情况。

I have a few textbox's, default style, etc. I set an explicit maxwidth and maxheight to prevent resize when the text exceeds the default width of the textbox. 我有一些文本框,默认样式等。我设置了显式的maxwidth和maxheight,以防止当文本超过文本框的默认宽度时调整大小。 The issue is that the text wraps to the next line, but I only want single line. 问题是文本自动换行到下一行,但是我只想一行。 So I set maxlines to 1 and textwrapping to NoWrap. 因此,我将maxlines设置为1,并将textwrapping设置为NoWrap。 That's fine. 没关系。

Now the carat and typed text disappears under the edges of the textbox when the width is exceeded and the only way I can get the carat and newly typed text back into view is by pressing the left and right arrows. 现在,当超过宽度时,克拉和键入的文本会消失在文本框的边缘下方,而使克拉和新键入的文本重新显示的唯一方法是按向左和向右箭头。 Coming from MFC and using textboxes all the time with HTML, I would have thought the default behaviour would be to have the textbox content scroll with the carat or am I missing something here? 来自MFC并一直使用HTML文本框,我本来以为默认行为是使文本框内容与克拉一起滚动,或者我在这里错过了什么吗?

Thank you, 谢谢,

Ash

What you are requesting is actually the default behavior. 您要求的实际上是默认行为。 Start with an empty grid and place a textbox on it. 从一个空的网格开始,并在其上放置一个文本框。 Type some text into the box and the text view will scroll with the caret. 在框中输入一些文本,文本视图将与插入符号一起滚动。

Below is the XAML I tested with, perhaps you have a style interfering with it? 下面是我测试过的XAML,也许您有干扰它的风格?

 <Grid>
    <TextBox MaxWidth="20" Height="20"></TextBox>
 </Grid>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM