Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Chart > databind an ItemMapping FieldName

Not answered databind an ItemMapping FieldName

Feed from this thread
  • James avatar

    Posted on Feb 3, 2012 (permalink)

    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 ...so 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:SeriesMapping>
                                <telerik:SeriesMapping.SeriesDefinition>
                                    <telerik:PieSeriesDefinition 
                                        LegendDisplayMode="DataPointLabel"
                                        ShowItemLabels="False" 
                                        ShowItemToolTips="True">
                                        <telerik:PieSeriesDefinition.Appearance>
                                            <telerik:SeriesAppearanceSettings ></telerik:SeriesAppearanceSettings>
                                        </telerik:PieSeriesDefinition.Appearance>
                                    </telerik:PieSeriesDefinition>
                                </telerik:SeriesMapping.SeriesDefinition>
                                <telerik:ItemMapping DataPointMember="YValue" FieldName="Commission" />
                                <telerik:ItemMapping DataPointMember="LegendLabel" FieldName="Symbol" />
                            </telerik:SeriesMapping>
    

    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

    Reply

  • Yavor Yavor admin's avatar

    Posted on Feb 8, 2012 (permalink)

    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,
    Yavor
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Chart > databind an ItemMapping FieldName
Related resources for "databind an ItemMapping FieldName"

WPF Chart Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]