Change Textbox/Passwordbox trigger

Nov 17, 2010 at 10:25 PM

Hi all,


I was wondering what the best method is to change the Bind behaviour of the Textbox and Passwordbox control. 

Now the underlying VM property changes on each keystroke (a TextChange event is added in the framework).

Normally this behaviour is preferred (and thus the default), but when working with WCF RIA Services this behaviour can cause problems. 

I have an RIA entity with a RegularExpression (for an email) validation attribute on one of its properties, when bind to a textbox the validation is handled correctly.

The problem is that the validation should only occur on FocusLost and not on TextChanged, any ideas on this?



Nov 18, 2010 at 3:12 AM

Hmm. That's tricky. Is there any way via reflection or convention that you could determine which properties should not have the TextChanged behavior?

Nov 18, 2010 at 6:12 PM

I looked at a suitable property that I could use with reflection to determine the behaviour, but couldn't find one.

At this moment I think the best solution is to create a "naming" convetion that if the control name ends with "_Focus" no TextChanged event will be added. 

This also means that the binding to the VM needs to be created manually in the View instead of auto resolving it by CM, or is there a better way for that?