Keypress event in WPF to validate integer input is replaced by PreviewTextInput in C#
In WPF we don't have keypress event, generally people used keypress event in windows forms application to validate text input. Now in this example I have showed how you can validate input from textbox using PreviewTextInput event. In this example I validated input to accept float values, you can use this to validate integer or any other number type validation.
Code used in example is:
Title="MainWindow" Height="350" Width="525">
<TextBox Width="400" Height="50" PreviewTextInput="TextBox_PreviewTextInput" />