I'm using a text box to enter some details. What I want is, when I press enter of the soft keyboard, I want the cursor to move to the next line.
in xaml,
<TextBox x:Name="TextBox"
BorderThickness="1"
KeyDown="TextBox_KeyDown"
Background="Transparent"
TextChanged="TextBox_TextChanged_1"
HorizontalAlignment="Left"
Height="198"
argin="10,172,0,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
Width="436"/>
In Code behind,
private void TextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.Enter)
{
// How to handle??
}
}
How to handle?? Thanks in advance!
You don't need to handle the Enter key in that way.
You can simply set the property AcceptsReturn to true:
<TextBox x:Name="TextBox"
AcceptsReturn="True"
.....
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.