I have a WPF form where a text box and label is present.In the "Lost Focus" event of text box, i am doing some validation and if the validation fails i will show an error message in the label and put focus back on the textbox. The problem is since i put the focus back on the text bos,the "Lost_Focus event s again fired and my validation function being called recursively and i am getting a "StackOverflow" exception
An unhandled exception of type 'System.StackOverflowException' occurred in
mscorlib.dll
If i comment the line of putting cursor/focus in the textbox, everything works well. But i need the cursor to be in the textbox if validation fails
Any thoughts how to get rid of this ?