New to Telerik UI for WPF? Download free 30-day trial

Data Binding Support Overview

Data binding allows you to establish a link between the UI and the underlying business logic and keep them synchronized. It means that when a value is changed in the business layer, that change is automatically populated to the UI and vice versa. Of course, in order to work, you have to implement the proper notification or to use objects that have already implemented it.

Binding to RadChart involves the following three properties:

  • RadChart.ItemsSource - gets or sets the data source used to generate the content of the chart control. Elements can be bound to data from a variety of data sources in the form of common language runtime (CLR) objects and XML - see the list of the supported data sources bellow.

  • RadChart.SeriesMappings - a collection containing SeriesMapping elements. SeriesMapping defines the chart's type and how to map the data from the data source to the chart's DataPoints. Each SeriesMapping contains a collection of ItemMapping objects, each one defining how the properties of the data source elements map to the values required by the chart (YValue, XValue, XCat, etc.). RadChart also supports automatic binding mode (when no series mappings are defined). Please take a look at the Data Binding with Automatic Series Mappings and Data Binding with Manual Series Mapping topics for more information.

  • RadChart.DefaultSeriesDefinition - gets or sets the default series type for a data bound chart.

Supported Data Sources

You can bind RadChart to a data source that implements one of the following interfaces:

  • IEnumerable - supports simple iteration of a collection. See the MSDN article for more on IEnumerable.

  • ICollection - extends IEnumerable and supports size, enumerator, and synchronization methods for collections.

  • IList - extends ICollection and is the base class for lists.

  • IBindingList - extends IList and supports binding to a data source.

  • IListSource - provides functionality to an object to return a list that can be bound to a data source.

  • Data binding to a collection of collections or nested collections.

Change Notification Support

RadChart also provides full support for change notification - changes in data sources that implement the INotifyCollectionChangedor the IBindingList interfaces are properly tracked and reflected by the UI.

Some of the implementations of these interfaces include:

RadChart also allows you to bind to DataSourceProvider sources (e.g. XmlDataSourceProvider and ObjectDataProvider).

Be careful when you set as data source collections, where you dynamically add/remove items. Some of the charts, like the Line Chart, requires the data to be sorted by the property bound to XValue in order to properly visualize the chart.

Data binding scenarios

See Also

In this article