This example shows how to detect when the Enter key is pressed on the keyboard.
when the user presses the Enter key in the TextBox, the input in the text box appears in another area of the user interface (UI).
The following C# creates the user interface, which consists of a StackPanel, a TextBlock, and a TextBox.
private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
textBlock1.Text = "You Entered: " + textBox1.Text;
}
}








Reply With Quote
