WPF data binding
Posted liangzi4000
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
以上是关于WPF data binding的主要内容,如果未能解决你的问题,请参考以下文章
C# wpf 中 一个窗体中的texbox内容显示另一个窗体中的listview中的内容。如何实现
[WPF]WPF Data Virtualization和UI Virtualization
将DataTable数据绑定到DataGrid - 代码背后