In WPF need to trap the keys entered in a textblock to keep the user from entering anything but digits,cap letters and navigation keys (Backspace, Arrows, etc).
Thanks!
In WPF need to trap the keys entered in a textblock to keep the user from entering anything but digits,cap letters and navigation keys (Backspace, Arrows, etc).
Thanks!
First there is a Filtered Text Control available here that does simple masking
The simple way is to handle the PreviewTextInput Event with something like this.
Private Sub TextBox1_PreviewTextInput(ByVal sender As Object, ByVal e As System.Windows.Input.TextCompositionEventArgs) Handles TextBox1.PreviewTextInput
Dim Character As Char = Convert.ToChar(e.Text)
If Char.IsDigit(Character) Then
e.Handled = False
ElseIf Char.IsLetter(Character) And UCase(Character) = Character Then
e.Handled = False
Else
e.Handled = True
End If
End Sub