PDA

View Full Version : KeyUp + Delay + Show Validation Message



Nineteen
November 19th, 2008, 09:47 PM
Hi,

We're currently working on some validation fields in WPF.

We want users to be able to type in the field and when they stop typing to display a validation message (where appropriate) after a small delay.

Eg:
Step 1) User begins to type in Field
Step 2) When user stops typing start to count to 1 second, when 1 second is reached go to Step 3 else if user starts to type again reset and repeat Step 2.
Step 3) Display validation message if field format is incorrect.

Is there any references we can use to see how this may be done or does anyone have an idea?

Cheers!

kirupa
November 19th, 2008, 10:31 PM
Hi Nineteen!
That's actually pretty doable. Simply listen to your TextChanged event on the text field. Your event handler can have a timer that gets reset each time you type. When you stop typing, your timer gets a chance to run to completion. You can add a few lines of code to do your validation when the timer runs.

Cheers!
Kirupa :)