WPF data binding

Binding这个类包含以下几个常用的属性:

ElementName: Gets or sets the name of the elements to use as the binding source object. [Default is null]

Source: Gets or sets the object to use as the binding source. 

RelativeSource: Gets or sets the binding source by specifying its location relative to the position of the binding target.

Converter: Gets or sets the converter to use.

Mode: Gets or sets a value that indicates the direction of the data flow in the binding.

Path: Gets or sets the path to the binding source property.

StringFormat: Gets or sets a string that specifies how to format the binding if it displays the bound value as a string.(Inherited from BindingBase.)

  • Only one of the three properties, ElementName, Source, and RelativeSource, should be set for each binding, or a conflict might occur. 
  • By default, bindings inherit the data context specified by the DataContext property
  • Path is the default property of a binding. {Binding PropertyName} 等价于 {Binding Path=PropertyName}
  • {Binding} is equivalent to {Binding Path=.}, which binds to the current source

 

参考链接:

https://msdn.microsoft.com/en-us/library/system.windows.data.binding(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/ms750413.aspx

http://stackoverflow.com/questions/1906587/wpf-bind-to-itself

https://msdn.microsoft.com/en-us/library/ms746695(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/ms752347(v=vs.110).aspx

posted @ 2016-11-16 18:04  liangzi4000  阅读(206)  评论(0编辑  收藏  举报