DataBinding
Databinding for the Sparkline control involves the correlation between the business logic/data, and the visualization of the control.
The DataBinding involves the following three properties:
SparkLine.ItemsSource - gets or sets the data source used to generate the content of the sparkline 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.
Sparkline.XValuePath - sets the name of the property from the underlying datasource, which will determine the position of each datapoint along the x axis.
Sparkline.YValuePath - sets the name of the property from the underlying datasource, which will determine the position of each datapoint along the y axis.
Supported Data Sources
You can bind RadSparkline 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.
Change Notification Support
RadSparkline also provides full support for change notifications - changes in data sources that implement the INotifyCollectionChanged, as well as INotifyPropertyChanged, are properly tracked and reflected by the UI.
Some of the implementations of these interfaces include:
1.Binding To Collection of Doubles
The following code snippets demonstrate how to databind RadSparkLine to generic List of double type
Create new RadLinearSparkline in XAML and turn on visibility for Indicators as follows:
2.Binding To a List of Business Objects
If you have a list of business objects and you want to bind it to the RadSparkLine control here is how to do it: