0

I need a textbox where the user only can work with uppercase characters. Also some special characters like - _ and <.

I wonder if there could be a ways to catch the PreviewKeyDown or KeyDown Event to convert the pressed keys to UpperCase.

MyTextBox1 > System.Windows.Input.KeyEventArgs > Key is ReadOnly.

Any idea how that can be managed?

Nasenbaer
  • 4,810
  • 11
  • 53
  • 86
  • possible duplicate http://stackoverflow.com/questions/1103765/wpf-textbox-how-to-define-some-restriction – LPL Nov 09 '11 at 10:11
  • 1
    a dup, but a different and simple answer...brillant! – kenny Nov 09 '11 at 10:19
  • no dublicate because just I searched on `KeyDown` (as idea) like the other question but only needed UpperCase and in this case I do not need to touch my huge way using `KeyDown` just WPF. – Nasenbaer Nov 09 '11 at 11:05

1 Answers1

3

You don't need to do that, you can just use the CharacterCasing property

<TextBox CharacterCasing="Upper" />

Other than that if you need a more general answer, look at my answer to How do I get a TextBox to only accept numeric input in WPF? here

Community
  • 1
  • 1
Ray
  • 45,695
  • 27
  • 126
  • 169
  • What a great simple answer. I thought it is not too difficult but not thought that is that easy! Thanks for quick reply Ray! – Nasenbaer Nov 09 '11 at 10:14