It is impossible and makes no sense. If you want to handle some event triggered when some property of the instance of the type
MyObject changes its value, you need to have the event
PropertyChanged
in this type and nowhere else.
Not in MyCaller
or some other type.
Saying "I don't have the source code for
MyObject
" sets a period in this story. You cannot use this type this way. However, you can do it in a derived class.
If the property
MyObject.Name
was virtual, you could override it in your class where you could add the
PropertyChanged
event, invoking it in the setter of
MyObject.Name
. That would, in turn, make your derived class sealing the invocation of this event, because any event instance can only be invoked in its declaring class, which can be considered as an important
fool-proof feature. Please see my past answer:
UserControl custom event[
^].
But you class
MyObject
, without changing its code, is completely closed for any modifications of its property behavior, due to its non-virtual declaration. Anyway, as a library class it would be useless in all respects. :-)
—SA