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

Data binding basics

In WPF, we use the Binding class to create our bindings. In general, it is fair to say that every binding will contain four constituent parts. Let's take a look at them now:

  • The first is the binding source; typically, this will be one of our View Models. 
  • The second is the path to the property from the source object that we would like to data bind to.
  • The third is the binding target; this will typically be a UI control.
  • The fourth is the path to the property of the binding target that we want to data bind to.

If one of our bindings does not work, it is most likely that one of these four things has not been set correctly. It is important to stress that the target property will typically be from a UI control, because there is a data binding rule that states that the binding target must be a Dependency Property. The properties of most UI controls are Dependency Properties, and so, this rule simply enforces that data normally travels in the direction from our View Model data sources to the binding target UI controls.

We'll examine the direction of data bound data traversal later in the chapter, but let's first focus on the syntax that is used to specify the value of the Binding.Path property.

主站蜘蛛池模板: 梅河口市| 衡水市| 大同县| 九龙县| 阿瓦提县| 容城县| 奈曼旗| 日照市| 灵璧县| 曲靖市| 浦县| 金秀| 马尔康县| 洞头县| 盐城市| 周至县| 宝丰县| 容城县| 苍南县| 平南县| 察雅县| 剑河县| 阿城市| 赤壁市| 蓝田县| 独山县| 宕昌县| 彰化县| 蚌埠市| 云浮市| 榆社县| 多伦县| 平陆县| 兴海县| 昆明市| 廉江市| 镇江市| 汾阳市| 肃南| 盐池县| 类乌齐县|