silverlight属性改变事件通知
2021-07-19 18:07
标签:bsp span over his text val 事件通知 ide ons 工作中遇到silverlight本身没有提供的某些属性改变事件,但又需要在属性改变时得到通知,Google搬运stack overflow,原地址 silverlight属性改变事件通知 标签:bsp span over his text val 事件通知 ide ons 原文地址:http://www.cnblogs.com/missile/p/7058138.html /// Listen for change of the dependency property
public void RegisterForNotification(string propertyName, FrameworkElement element, PropertyChangedCallback callback)
{
//Bind to a depedency property
Binding b = new Binding(propertyName) { Source = element };
var prop = System.Windows.DependencyProperty.RegisterAttached(
"ListenAttached"+propertyName,
typeof(object),
typeof(UserControl),
new System.Windows.PropertyMetadata(callback));
element.SetBinding(prop, b);
}
RegisterForNotification("Text", this.txtMain,(d,e)=>MessageBox.Show("Text changed"));
RegisterForNotification("Value", this.sliderMain, (d, e) => MessageBox.Show("Value changed"));
文章标题:silverlight属性改变事件通知
文章链接:http://soscw.com/index.php/essay/106362.html