-
Notifications
You must be signed in to change notification settings - Fork 75
WeakEvent
Rico Suter edited this page Jun 3, 2015
·
2 revisions
- Package: MyToolkit
- Platforms: All (PCL)
When adding an event this way the object can be destroyed even the event handler is still registered. You should ONLY use this class if there is no way to know when to deregister an event (e.g. in the Unloaded event of a control) because it may still have some performance impact.
var handler = WeakEvent.RegisterEvent<
INotifyPropertyChanged,
PropertyChangedEventHandler,
PropertyChangedEventArgs>(
h => (o, e) => h(o3, e),
h => item.PropertyChanged += h,
h => item.PropertyChanged -= h,
this, OnPropertyChanged);Generic parameters
- Type of the sender/object with the event
- Type of the event handler
- Type of the event arguments (the first method parameter is not needed for generic args e.g. if the event is of type
EventHandler<TArgs>)