官术网_书友最值得收藏!

Data binding

One often overlooked aspect of the MVVM pattern is its requirement for data binding. We could not have the full Separation of Concerns without it, as there would be no easy way of communicating between the Views and View Models. The XAML markup, data binding classes, and ICommand and INotifyPropertyChanged interfaces are the main tools in WPF that provide this functionality.

The ICommand interface is how commanding is implemented in the .NET Framework. It provides behavior that implements and even extends the ever useful Command pattern, in which an object encapsulates everything needed to perform an action. Most of the UI controls in WPF have Command properties that we can use to connect them to the functionality that the commands provide.

The INotifyPropertyChanged interface is used to notify binding clients that property values have been changed. For example, if we had a User object and it had a Name property, then our User class would be responsible for raising the PropertyChanged event of the INotifyPropertyChanged interface, specifying the name of the property each time its value was changed. We'll look much deeper into all of this later, but now let's see how the arrangement of these components help us.

主站蜘蛛池模板: 屏南县| 屏南县| 修武县| 九寨沟县| 麻栗坡县| 松溪县| 呼和浩特市| 永胜县| 景洪市| 扶风县| 友谊县| 扶沟县| 雅安市| 左云县| 宁明县| 常宁市| 沙田区| 清丰县| 宜都市| 伊金霍洛旗| 武胜县| 吉木乃县| 调兵山市| 安塞县| 保康县| 伊川县| 舒兰市| 句容市| 贡山| 丰都县| 孝义市| 柏乡县| 泗洪县| 景宁| 县级市| 贵港市| 景德镇市| 姜堰市| 绥中县| 赣州市| 平江县|