This is a migrated thread and some comments may be shown as answers.

databind an ItemMapping FieldName

1 Answer 21 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
James asked on 03 Feb 2012, 03:18 PM
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

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 08 Feb 2012, 10:29 AM
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 >>
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question