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

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.

主站蜘蛛池模板: 通辽市| 洛南县| 梁山县| 保定市| 敦化市| 宁蒗| 瓦房店市| 汝城县| 山丹县| 讷河市| 宣威市| 镇沅| 长汀县| 汤原县| 新郑市| 河间市| 汝南县| 浦县| 鹤岗市| 中西区| 塘沽区| 隆安县| 徐水县| 凉城县| 岗巴县| 万山特区| 苍山县| 当雄县| 柘城县| 新和县| 平武县| 黑水县| 浦江县| 巴东县| 夏邑县| 锡林浩特市| 滦平县| 托里县| 兴仁县| 宕昌县| 普兰店市|