EditCategory
Data Binding
EditQuestion
What's the difference between ItemsSource, DataContext, Binding, and DataSourceProvider?
EditAnswer
Obviously, these are all related to data binding ,but they play different roles. These concepts can be categorized into three groups.
Data definition
DataSourceProvider and its derived classes XmlDataProvider and ObjectDataProvider are used to define the data itself. They can be declared in code or in XAML (see related links). For instance, XmlDataProvider allows you to create an entire XML document in XAML that will serve as the data source of a binding.
Binding definition or description
Binding is a class that allows the description of a binding between a source and a target. It is the "glue" that links a data store, aka source (database, collection, etc.), with a data consumer, aka target (user interface, web service, etc.). A binding is always defined by four pieces of information: the data source, a field (or property) of the data source, the data target and a DependencyProperty of the target.
The DataContext class is used to define the "source" part of a binding. It is useful to share one binding source across multiple object and/or dependency properties.
Binding implementation
Most dependency properties can be assigned a binding, making use of the previously described concepts. However, objects are free to expose their own way of supporting binding.
The ItemsControl's ItemsSource property is a good example in that it expects a IEnumerable object and not the four components of Binding already explained.
EditKeywords
databinding