RadChart Multiple Series MVVM

2 posts, 0 answers
  1. Derek
    Derek avatar
    3 posts
    Member since:
    May 2011

    Posted 14 Oct 2011 Link to this post

    Hello,

    I am trying to use the RadChart to bind to a Nested Collection.  I would like every member of the parent collection to represent a spline series that has a property named CollectionName property to bind to the Legend Label.  Then I want to have each child collection have its members mapped to the points along the spline.  This code works:

     

     

     

    <Telerik:RadChart ItemsSource="{Binding Path=SeriesCollection,Mode=TwoWay}" x:Name="chartcontentseries" >

    <telerik:RadChart.DefaultSeriesDefinition>

    <telerik:SplineSeriesDefinition></telerik:SplineSeriesDefinition>

    </telerik:RadChart.DefaultSeriesDefinition>

    <telerik:RadChart.SeriesMappings>

    <telerik:SeriesMapping CollectionIndex="0" LegendLabel="{Binding Path=CollectionName}">

                           (I have to have this set)       (This does not display the collection name!)

    <telerik:ItemMapping FieldName="Percentage" DataPointMember="YValue"></telerik:ItemMapping>

    </telerik:SeriesMapping>

    </telerik:RadChart.SeriesMappings>

     

    </telerik:RadChart>


    However, I have to have a SeriesMapping for every collection that is added which is undesirable and the LegendLabel does not display the collection name.  Is there a way in XAML to set up a template for the series and have them automatically added and removed when the collection changes?  Or do I have to do it all manually in code behind?
  2. Nikolay
    Admin
    Nikolay avatar
    385 posts

    Posted 19 Oct 2011 Link to this post

    Hi Derek,

    You would have to handle the collection changes in code behind, unfortunately having templates for the series and doing this in XAML is not supported. Currently RadChart requires a series mapping for each series that is visible on the screen.

    You can bind your SeriesMapping to your view model and modify them from there. Keep in mind that the SeriesMappings are configuration objects and are not included in the visual tree, that's why they don't have DataContext and the bindings don't work as expected, which is why the CollectionName is not displayed as well.You would have to create a CollectionName property in your view model and map it to LegendLabel in order to display it correctly.

    All the best,
    Nikolay
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top