I am looking at this blog, and I am trying to translate the snippet to VB.
I'm having difficulties with this line:
NotifyCollectionChangedEventHandler handlers = this.CollectionChanged;
NOTE: CollectionChanged is an event of this ('this' is an override of ObservableCollection<T>
).
To raise the event,
OnCollectionChanged
should work fine. If you want to query it you have to get more abusive and use reflection (sorry, example is C# but should be virtually identical - I'm not using any language-specific features here):et voila; the handler or handlers (via
GetInvocationList()
).So basically in your example (regarding that post), use:
Literally, it should be something like
(can't tell since I don't know the exact types)
But note that you raise events in VB using
RaiseEvent
Duh. After having finally seen and read the blog posting you linked, here’s the answer:
In VB, you need to declare a custom event to override the
RaiseEvent
mechanism. In the simplest case, this looks like this:In your case, the
RaiseEvent
routine is slightly more involved to reflect the additional logic, but the gist remains the same.