[]
        
(Showing Draft Content)

Collection of Objects

Data binding should be used when you have a collection of objects where each object includes numerical properties. There are at least two chart properties involved in the data binding process.

  • ItemsSource property – The source where the collection of objects are assigned to.
  • ValueBinding property – Gets or sets the value binding for the chart's data series. Specifies what object property provides the data value.

Suppose we have the array of points in resources:

x:Array x:Key="points" Type="Point">
       <Point>0,0</Point>
       <Point>10,0</Point>
       <Point>10,10</Point>
       <Point>0,10</Point>
       <Point>5,5</Point>
</x:Array>

The following XAML fragment presents the chart with two data series, one is bound to X coordinate of points, and the other is bound to Y coordinate:

<c1chart:C1Chart Name="chart2">
       <c1chart:C1Chart.Data>
              <c1chart:ChartData
 ItemsSource="{Binding Source={StaticResource points}, Path=Items}">
                     <c1chart:DataSeries ValueBinding="{Binding Path=X}"/>
                     <c1chart:DataSeries ValueBinding="{Binding Path=Y}"/>
              </c1chart:ChartData>
       </c1chart:C1Chart.Data>
</c1chart:C1Chart>

The next sample shows the series that uses both coordinates of points at once; note it is the instance of XYDataSeries class that handles two sets of data values which correspond to x- and y-coordinates:

<c1chart:XYDataSeries
       XValueBinding="{Binding Path=X}"
       ValueBinding="{Binding Path=Y}"/>

See Also

Observable Collection