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

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.

主站蜘蛛池模板: 罗田县| 滦平县| 巴楚县| 乌鲁木齐县| 龙井市| 永和县| 山西省| 靖远县| 贡觉县| 垦利县| 靖远县| 三门县| 古浪县| 香港| 兰考县| 健康| 常山县| 建水县| 隆林| 贵溪市| 修武县| 恩施市| 封开县| 宿州市| 大连市| 方正县| 肇源县| 台江县| 施秉县| 泰和县| 怀柔区| 庆阳市| 东兴市| 金溪县| 大安市| 札达县| 祁东县| 同江市| 兰考县| 嘉义市| 灵川县|