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

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.

主站蜘蛛池模板: 泸州市| 镶黄旗| 鹰潭市| 丹江口市| 五华县| 日土县| 远安县| 广东省| 唐山市| 呈贡县| 青田县| 台南县| 遂平县| 桃园县| 富平县| 海伦市| 长沙市| 泸定县| 威宁| 漾濞| 天峻县| 双江| 都昌县| 东丽区| 乌鲁木齐县| 淄博市| 饶平县| 宁陕县| 都兰县| 霍林郭勒市| 泽库县| 原阳县| 麻栗坡县| 十堰市| 泾源县| 绩溪县| 镇康县| 新巴尔虎左旗| 柳林县| 监利县| 宜宾县|