I'm using a ChartSeriesProvider to display multiple LineSeries charts. Everything is working well except the legend items. I would like the Title property to display each series name, but instead I'm getting the same series name (the first one) for all of the legend titles.
If I do it via XAML it works, as shown in your example:
<Setter Property="LegendSettings">
<Setter.Value>
<telerik:SeriesLegendSettings x:Name="jobsLegendSettings" Title="{Binding SeriesName}" />
</Setter.Value>
</Setter>
However, I must do it via code behind. Here is my current code which doesn't work (I only pasted the relevant code, I hope it's enough):
Style style = new Style();
descriptor.Style = style;
jobsSeriesProvider.SeriesDescriptors.Add(descriptor);
style.TargetType = typeof(Telerik.Windows.Controls.ChartView.LineSeries);
Binding binding = new Binding();
binding.Path = new PropertyPath("SeriesName");
binding.Source = JobsData;
SeriesLegendSettings legendSettings = new SeriesLegendSettings();
BindingOperations.SetBinding(legendSettings, SeriesLegendSettings.TitleProperty, binding);
var legendSetter = new Setter
{
Property = Telerik.Windows.Controls.ChartView.LineSeries.LegendSettingsProperty,
Value = legendSettings,
};
style.Setters.Add(legendSetter);