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

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.

主站蜘蛛池模板: 义马市| 墨玉县| 神农架林区| 鄯善县| 奉节县| 南汇区| 宁南县| 丹阳市| 南京市| 太康县| 内江市| 手游| 福海县| 海盐县| 确山县| 延长县| 龙胜| 阿尔山市| 阿克苏市| 尉氏县| 巴林左旗| 综艺| 金湖县| 册亨县| 琼结县| 青龙| 郎溪县| 西安市| 隆林| 鄱阳县| 南京市| 民勤县| 丹寨县| 商河县| 大邑县| 龙州县| 五莲县| 扎赉特旗| 定结县| 浦东新区| 调兵山市|