This topic has not yet been rated - Rate this topic

DependencyPropertyDescriptor.AddValueChanged Method

Enables other objects to be notified when this property changes.

Namespace:  System.ComponentModel
Assembly:  WindowsBase (in WindowsBase.dll)
public override void AddValueChanged(
	Object component,
	EventHandler handler
)
You cannot use methods in XAML.

Parameters

component
Type: System.Object
The component to add the handler for.
handler
Type: System.EventHandler
The delegate to add as a listener.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
DependencyPropertyDescriptor.AddValueChanged roots your component for GC! (object leak)

Beware that this method will ultimately store a reference to 'component' as a key in a static hashtable. This will root your component and it will never be garbage collected, unless you call RemoveValueChanged when you are done.

Consider implementing (and using) IDisposable or using a weak reference method, such as data binding through a Binding object. Also see http://agsmith.wordpress.com/2008/04/07/propertydescriptor-addvaluechanged-alternative/ for a discussion.