WeakEventStrategy
Gets or sets how the PropertyChanged event keeps weak or strong references.
Declaration
public WeakEventStrategy WeakEventStrategy { get; set; }Property Value
| Type | Description |
|---|---|
| WeakEventStrategy |
Remarks
Setting this property to Default is equivalent to AlwaysWeak.
Setting this property to AlwaysWeak forces the event to hold only weak references. A ConditionalWeakTable<TKey, TValue> is used to bind the lifetime of the delegate to its target even if the registering object does not keep a reference to the delegate. This does not prevent the target object from being collected along with the delegate, which may happen implicitly when a lambda or local function with a closure is used as an event handler. In this case, no reference to the closure class is retained.
Setting this property to AlwaysStrong forces the event to hold only strong references. This may prevent components that do not support weak event behavior from having subscribed delegates collected. However, it may cause memory leaks if delegates are not unregistered from the event.