简体   繁体   English

具有顶部垂直对齐的多行文本框

[英]A Multi-Line TextBox with Top Vertical Alignment

I'm trying to create a multi-line TextBox to allow the user to enter text. 我正在尝试创建多行TextBox以允许用户输入文本。

I have: 我有:

<TextBox Grid.Row="0"
    Height="107"
    ScrollViewer.VerticalScrollBarVisibility="Auto"
    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
    AcceptsReturn="True"
    HorizontalAlignment="Left"
    Margin="164,80,0,0"
    VerticalAlignment="Top"
    Width="237"
    Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MaxLength="300" 
    TextWrapping="Wrap"/>

However the text is centered vertically and I can't seem to find a TextAlignment property for vertical alignment. 但是文本垂直居中,我似乎找不到用于垂直对齐的TextAlignment属性。

I subsequently wrapped the textbox in a border and removed the Height specification, however when I click in the area below the textbox (but within the border) I would like the textbox to get focus and I can't seem to find a way to do this. 随后,我将文本框包裹在边框中并删除了Height规范,但是,当我单击文本框下方的区域(但在边框内)时,我希望文本框获得焦点,而我似乎找不到解决方法这个。

Has anyone come across this issue before and found a solution? 有没有人遇到过这个问题并找到了解决方案?

So after discussion in comments. 因此在评论后进行讨论。 This is the Answer: 这是答案:

<TextBox Height="107"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
AcceptsReturn="True"
HorizontalAlignment="Left"
Margin="657,237,0,0"
VerticalAlignment="Top"
Width="237"
Text="Text alignment left and top" MaxLength="300" 
TextWrapping="Wrap" VerticalContentAlignment="Top" HorizontalContentAlignment="Left"/>

No question should be left unanswered! 毫无疑问,我们将为您解答! :) :)

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

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