This project has moved and is read-only. For the latest updates, please go here.

Numeric Only IntegerUpDown For Keyboard Input

Jul 6, 2012 at 8:06 PM

I solved this problem hooking into PreviewTextInput and checking for 0-9+- then setting e.Handled = true to cancel the input.

But before I had figured out that solution I tried using a Behavior (since I didn't want to modify the source) and I was thwarted by the piece of code that did a:

var textBox = target as TextBox;

Which brought up the question: What is the proper way for a Behavior to "reach into" a composite control and get a reference to a control contained within?

Do we have to resort to using the x:Name and walking the VisualTree or is there a simpler way?