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

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.

主站蜘蛛池模板: 榆社县| 哈密市| 定西市| 嘉禾县| 古田县| 麦盖提县| 张家界市| 安溪县| 祁连县| 洛阳市| 收藏| 噶尔县| 盱眙县| 贵阳市| 平陆县| 松滋市| 昭苏县| 清苑县| 宜昌市| 隆回县| 保定市| 嘉义县| 象山县| 荆州市| 闵行区| 全椒县| 沂水县| 平南县| 库车县| 山阴县| 满城县| 墨江| 宝鸡市| 简阳市| 彰化县| 井陉县| 饶阳县| 三亚市| 会同县| 宣威市| 海安县|