Ninjatrader Matt showed me some code here:
however, I want to be able to press delete / backspace and have it function like a normal textbox. I'm using the following code right now as a workaround, but i can only append text to the end. What is the proper way to accomplish this?
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) { TextBox textBoxSender = (TextBox) sender; if(e.Key >= Key.D0 && e.Key <= Key.D9 || (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9)) { string s = e.Key.ToString(); textBoxSender.Text += s.Substring(s.Length-1,1); // handle the keydown event for the text box e.Handled = true; } }
Comment