databind an ItemMapping FieldName

2 posts, 0 answers
  1. James
    James avatar
    5 posts
    Member since:
    Aug 2011

    Posted 03 Feb 2012 Link to this post

    Hi, I have a chart in a view that I would like to use to display 3 different types of data in different instances of the view in one instance the view may be displayed to show Commission and in another  scenario the view may be used to display "Volume"  etc... I have one view which represents the chart and a view model that is used to define the data item to display (among other things) ...I would basically like to set one of the item mappings at runtime (but obviously I am using MvvM).

    This is my series definition
                                            <telerik:SeriesAppearanceSettings ></telerik:SeriesAppearanceSettings>
                                <telerik:ItemMapping DataPointMember="YValue" FieldName="Commission" />
                                <telerik:ItemMapping DataPointMember="LegendLabel" FieldName="Symbol" />

    and I was hoping to be able to do this (where the DataFieldName would be set in the view model depending on what that particular view instance should show  

    <telerik:ItemMapping DataPointMember="YValue" FieldName="{Binding ElementName=radChart1, Path=DataContext.DataFieldName}" />

    I get an error in Visual Studio, something about a null value. I have tried a number of  options for the binding but it doesn't seem to work so maybe it's not possible 

    My question is should I be able to do this and if not do you have any suggestions on how to achieve what I am trying to do.

    Thanks in advance
  2. Yavor
    Yavor avatar
    401 posts

    Posted 08 Feb 2012 Link to this post

    Hello James,

    Series Mappings and ItemMappings are used for configuring the chart series and are not part of the visual or the logical tree. You can data bind the SeriesMappings to your view model and modify it from there. I have prepared for you a small demo application that demonstrates this approach. Feel free to modify it as you wish.

    Kind regards,
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top