摘要: 一、观察者模式(一对多的对象归属,当一个对象发生了改变,它的所属对象自动通知和改变) System.ComponentModel.INotifyPropertyChanged,该接口是观察者模式的部分,当属性的值发生改变后去通知订阅者(使用者). 该接口仅包含一个事件event PropertyChangedEventHandler PropertyChanged,当类继承了该接口,并实现该事件即可完成通知,如下: public class Product : INotifyPropertyChanged { private string price; ... 阅读全文
posted @ 2012-03-30 21:42 wangyafei_it 阅读(858) 评论(0) 推荐(0) 编辑
摘要: Binding Validation Rules:<TextBox> <TextBox.Text> <Binding> <Binding.ValidationRules> <ExceptionValidationRule /> </Binding.ValidationRules> </Binding></TextBox.Text></TextBox>在WPF的验证中引入了ValidationRule验证规则概念,提供一种为检查用户输入的有效性而创建自定义规则的方法。属性:Validate 阅读全文
posted @ 2012-03-30 21:22 wangyafei_it 阅读(1719) 评论(2) 推荐(1) 编辑
摘要: Event:在Silverlight和WPF中没有使用.net的LCR事件,而是使用Routed路由事件,根本原因是因为Silverlight控件的节点树。一个简单的示例:public static readonly RoutedEvent MyRoutedEvent =EventManager.RegisterRoutedEvent("MyEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyClass));是不是很熟悉,没错和定义附加属性(依赖属性)的方式类似,解释下参数:public 阅读全文
posted @ 2012-03-30 12:39 wangyafei_it 阅读(2158) 评论(15) 推荐(3) 编辑