C# Class MahApps.Metro.Controls.PropertyChangeNotifier

AddValueChanged of dependency property descriptor results in memory leak as you already know. So, as described here, you can create custom class PropertyChangeNotifier to listen to any dependency property changes. This class takes advantage of the fact that bindings use weak references to manage associations so the class will not root the object who property changes it is watching. It also uses a WeakReference to maintain a reference to the object whose property it is watching without rooting that object. In this way, you can maintain a collection of these objects so that you can unhook the property change later without worrying about that collection rooting the object whose values you are watching. Complete implementation can be found here: http://agsmith.wordpress.com/2008/04/07/propertydescriptor-addvaluechanged-alternative/
Inheritance: System.Windows.DependencyObject, IDisposable
Afficher le fichier Open project: MahApps/MahApps.Metro Class Usage Examples

Méthodes publiques

Свойство Type Description
ValueProperty System.Windows.DependencyProperty

Private Properties

Свойство Type Description
OnPropertyChanged void

Méthodes publiques

Méthode Description
Dispose ( ) : void
PropertyChangeNotifier ( DependencyObject propertySource, DependencyProperty property ) : System
PropertyChangeNotifier ( DependencyObject propertySource, PropertyPath property ) : System
PropertyChangeNotifier ( DependencyObject propertySource, string path ) : System

Private Methods

Méthode Description
OnPropertyChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Method Details

Dispose() public méthode

public Dispose ( ) : void
Résultat void

PropertyChangeNotifier() public méthode

public PropertyChangeNotifier ( DependencyObject propertySource, DependencyProperty property ) : System
propertySource System.Windows.DependencyObject
property System.Windows.DependencyProperty
Résultat System

PropertyChangeNotifier() public méthode

public PropertyChangeNotifier ( DependencyObject propertySource, PropertyPath property ) : System
propertySource System.Windows.DependencyObject
property System.Windows.PropertyPath
Résultat System

PropertyChangeNotifier() public méthode

public PropertyChangeNotifier ( DependencyObject propertySource, string path ) : System
propertySource System.Windows.DependencyObject
path string
Résultat System

Property Details

ValueProperty public_oe static_oe property

Identifies the Value dependency property
public static DependencyProperty,System.Windows ValueProperty
Résultat System.Windows.DependencyProperty