ChartSeriesDescriptor.CollectionIndex Property

2 posts, 0 answers
  1. Lau
    Lau avatar
    1 posts
    Member since:
    Jun 2016

    Posted 06 Jul 2016 Link to this post


    Is this property Bindable? I have a Barseries and a Lineseries, the LineSeries should only apply to the last data series, if i put in the right index it works, but with binding no getter gets called.

  2. Martin Ivanov
    Martin Ivanov avatar
    1451 posts

    Posted 08 Jul 2016 Link to this post

    Hi Laurentius,

    The chart series descriptor doesn't have a data context and its properties cannot be bind. Or at least they won't know from where to get their bound properties. In short, no, the CollectionIndex property won't work with binding because it doesn't have a binding source.

    In order to achieve your requirement you can use the SeriesProvider SeriesDescriptorSelector and apply the proper descriptors to the series. Another approach could be to add a single abstract ChartSeriesDescriptor and subscribe for the SeriesProvider's SeriesCreated event, where you can get the CollectionIndex property from the view model and based on it, manually create the corresponding series.
        <telerik:ChartSeriesProvider Source="{Binding Data}"
                <telerik:ChartSeriesDescriptor ItemsSourcePath="MyDataPointsCollection" />                

    private void ChartSeriesProvider_SeriesCreated(object sender, ChartSeriesCreatedEventArgs e)
        var mySeriesModel = (MySeriesViewModel)e.Context;
        var index = mySeriesModel.CollectionIndex;
        CategoricalSeries series = null;
        if (index is the corresponding index of the line series)
            series = new LineSeries();
            series = new BarSeries();               
        series.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "MyCategory" };
        series.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "MyValue" };
        e.Series = series;

    I hope those approaches are suitable for your scenario.

    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top