This question is locked. New answers and comments are not allowed.
Hi,
I'm having some difficulties adding a binding to my radChart programmatically. When using the following XAML everything works as intended and the chart responds to changes to the underlying data:
However I need to add the series mappings dynamically, so I tried the following approach:
I then add the series to my chart like this:
But after doing this the chart is not responding to changes to the data like it did when I manually added the series mappings in the XAML. Any ideas on where the issue lies?
Thanks,
Jonathan
I'm having some difficulties adding a binding to my radChart programmatically. When using the following XAML everything works as intended and the chart responds to changes to the underlying data:
<telerik:RadChart.SeriesMappings> <telerik:SeriesMapping LegendLabel="test" ItemsSource="{Binding MyData}"> <telerik:SeriesMapping.SeriesDefinition> <telerik:StackedBarSeriesDefinition /> </telerik:SeriesMapping.SeriesDefinition> <telerik:ItemMapping DataPointMember="YValue" FieldName="Length" /> <telerik:ItemMapping DataPointMember="XCategory" FieldName="Name" /> </telerik:SeriesMapping></telerik:RadChart.SeriesMappings>However I need to add the series mappings dynamically, so I tried the following approach:
private SeriesMapping createSeries(string itemsSourceBindingPath, string legendLabel){ SeriesMapping series = new SeriesMapping() { LegendLabel = legendLabel, SeriesDefinition = new HorizontalStackedBarSeriesDefinition() }; series.ItemMappings.Add(itemMapping1); series.ItemMappings.Add(itemMapping2); BindingOperations.SetBinding(series, SeriesMapping.ItemsSourceProperty, new Binding(itemsSourceBindingPath)); return series;}I then add the series to my chart like this:
myChart.SeriesMappings.Add(createSeries("MyData", "Stuff"));myChart.SeriesMappings.Add(createSeries("MyData2", "More stuff"));myChart.SeriesMappings.Add(createSeries("MyData2", "Other stuff"));But after doing this the chart is not responding to changes to the data like it did when I manually added the series mappings in the XAML. Any ideas on where the issue lies?
Thanks,
Jonathan
