原文: 監聽WPF依賴屬性
當我們使用依賴屬性的時候,有時需要監聽它的變化,這在寫自定義控件的時候十分有用,
下面介紹一種簡單的方法。
如下使用DependencyPropertyDescriptor
DependencyPropertyDescriptor prop = DependencyPropertyDescriptor.FromProperty(
,
prop.AddValueChanged(this, this.OnMyDependencyPropertyChanged);
OnMyDependencyPropertyChanged為處理依賴屬性變化的事件。