When I press the Enter key, the KeyDown
event for the TextBox
is not fired if its AcceptsReturn
property is set to true. How can I identify when the Enter key is pressed for a TextBox
with AcceptsReturn
set to true
?
I tried the below code, and its works for me,
var textBox = new TextBox();
KeyEventHandler keyeventHandler = new KeyEventHandler(textBox_KeyDown);
textBox.AddHandler(TextBox.KeyDownEvent, keyeventHandler, true);
private void textBox_KeyDown(object sender, KeyEventArgs e)
{
*** now Enter Key gets fired eventhough when i set AcceptsReturn as True ***
}