简体   繁体   中英

A Multi-Line TextBox with Top Vertical Alignment

I'm trying to create a multi-line TextBox to allow the user to enter text.

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.

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.

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! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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