tags:

views:

59

answers:

1

I need to make a instance of some class to provide informations when it's property is being changed. Basically I am trying to implement a binding mechanism, which will watch the properties of the bound class and inform the system that the property has been changed.

The only solution I have found is to:

  • Add an event PropertyChanged using Emit
  • Get PropertyInfo
  • Get SetMethod IntPtr
  • Create new SetMethod using Emit which will encapsulate the old method and call the new Event
  • Change SetMethod using the new one

Is there any other way? And if not, is there any example how to do this or is there any existing solution?

Thanks for an answer.

+2  A: 

Is there any reason why you don't implement the INotifyPropertyChanged interface? I put together a quick sample in my answer to this question.

slugster
Yes, the main reason was to keep the binding process transparent without forcing the developers to change existing classes in order to use the new binding process. I am aware of INotifyPropertyChanged interface and it's behavior.Nevertheless the INotifyPropertyChanged is the most clean solution and I will probably use it.Thanks for your answer.
Martin Macak