Set ItemMapping FieldName Property By DataBinding

2 posts, 0 answers
  1. Martyn
    Martyn avatar
    18 posts
    Member since:
    Mar 2011

    Posted 09 May 2012 Link to this post


    In my RadChart, I currently set the FieldName of the SeriesMapping.ItemMapping statically. However, I want to be able to change which field within the dataset is being plotted dynamically at runtime.

    I've set the FieldName to be set with a binding and the chart initially draws, but, when I change the property being bound to, the chart does not re-draw to reflect this change.

                                    <telerik:StackedBarSeriesDefinition ShowItemToolTips="True" ItemToolTipFormat="{StaticResource HomeDealerChartCurrTooltip}"
                                                                 ItemLabelFormat="{StaticResource OverspendTooltipLabelFormat}" ItemStyle="{StaticResource StackedBarDefaultStyle}">
                                            <telerik:InteractivitySettings HoverScope="Series" SelectionScope="Item" />
                                    <telerik:ItemMapping FieldName="OverspendToDate" DataPointMember="YValue" />
                                    <telerik:ItemMapping FieldName="{Binding SelectedMeasure}" DataPointMember="XCategory" />

    Am I missing something?

    Thanks for any help,


  2. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 14 May 2012 Link to this post

    Hi Martyn,

    The ItemMappingCollection does not implement the INotifyItemChanged interface, hence it does not track changes in the items' properties. This means that you are not doing anything wrong, its just that this behavior is not expected.

    You can either create a new SeriesMapping and add it to the SeriesMappings collection (and remove the old mapping) or you need to call the Rebind method of the chart when you update the ItemMapping. 

    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top