C# Класс 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/
Наследование: System.Windows.DependencyObject, IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
ValueProperty System.Windows.DependencyProperty

Private Properties

Свойство Тип Описание
OnPropertyChanged void

Открытые методы

Метод Описание
Dispose ( ) : void
PropertyChangeNotifier ( DependencyObject propertySource, DependencyProperty property ) : System
PropertyChangeNotifier ( DependencyObject propertySource, PropertyPath property ) : System
PropertyChangeNotifier ( DependencyObject propertySource, string path ) : System

Приватные методы

Метод Описание
OnPropertyChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Описание методов

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

PropertyChangeNotifier() публичный Метод

public PropertyChangeNotifier ( DependencyObject propertySource, DependencyProperty property ) : System
propertySource System.Windows.DependencyObject
property System.Windows.DependencyProperty
Результат System

PropertyChangeNotifier() публичный Метод

public PropertyChangeNotifier ( DependencyObject propertySource, PropertyPath property ) : System
propertySource System.Windows.DependencyObject
property System.Windows.PropertyPath
Результат System

PropertyChangeNotifier() публичный Метод

public PropertyChangeNotifier ( DependencyObject propertySource, string path ) : System
propertySource System.Windows.DependencyObject
path string
Результат System

Описание свойств

ValueProperty публичное статическое свойство

Identifies the Value dependency property
public static DependencyProperty,System.Windows ValueProperty
Результат System.Windows.DependencyProperty