ComponentOne Chart for WPF and Silverlight
Chart for WPF and Silverlight / Chart Features / Data Binding / Collection of Objects
In This Topic
    Collection of Objects
    In This Topic

    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.

    Suppose we have the array of points in resources:

    XAML
    Copy Code
    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:

    XAML
    Copy Code
    <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:

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

     

    See Also