Auto execute method when property changes

Aug 2, 2011 at 6:02 AM

Hi Tony,

Is there a way in the toolkit that allows us to fire up a method when a property changes?

Thanks in advance.

Aug 2, 2011 at 9:15 AM
Yes, what you should do is subscribe to the PropertyChanged event in the ViewModel ctor and call the method from the handler.

this.PropertyChanged += (s, ea) => if(ea.PropertyName == "MyProp") Foo();

Aug 5, 2011 at 7:33 AM

Thanks Tony,

This works. Just was missing few curly braces to accept the IF in lambda expression:

PropertyChanged += (o, args) => { if (args.PropertyName == "PropertyName") Function(); };