I don't want my Textbox to be empty. I want it to keep the value before it is empty and write it when it is deleted. I'm using the KeyDown event but it doesn't work. Not triggering when the Delete key is pressed. Which event would be appropriate to trigger this correctly.
My Code
private static void textBox_KeyDown(object sender,KeyEventArgs e)
{
var textBox = sender as TextBox;
var maskExpression = GetMaskExpression(textBox);
var oldValue = textBox.Text;
if (e.Key == Key.Delete)
{
if (textBox.Text == string.Empty || textBox.Text == "")
{
MessageBox.Show("Not null");
textBox.Text = oldValue;
}
}
}