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

RadCartesianChart with SeriesProvider, binding on Title on SeriesLegendSettings not working

2 Answers 337 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Carlos Serrano
Top achievements
Rank 1
Carlos Serrano asked on 16 Jul 2013, 05:17 PM
Hello,

I am trying to do exactly the same thing as described at http://www.telerik.com/community/forums/wpf/charting-kit/radchartview-how-to-use-radlegend.aspx, but in Silverlight (we have the RadControls of Q2 2013).

But the binding on the Title of the SeriesLegendSettings does not produce anything (I do have one LegendItem in the RadLegend, but its Title is empty).

Here is a little code snippet:

<telerik:RadCartesianChart x:Name="Chart" VerticalAxis="{Binding VerticalAxis}" HorizontalAxis="{Binding HorizontalAxis}"
  <
telerik:RadCartesianChart.SeriesProvider>
    <telerik:ChartSeriesProvider Source="{Binding ChartSeries}" SeriesDescriptorSelector="{Binding SeriesSelector}"/>
  </telerik:RadCartesianChart.SeriesProvider>
</telerik:RadCartesianChart>

<
telerik:RadLegend Grid.Row="1" Items="{Binding LegendItems, ElementName=Chart}"/>

and the Style that is attached to the descriptor by means of the SeriesDescriptorSelector is the following:

<Style x:Key="ChartBarSeriesStyle" TargetType="telerik:BarSeries">
  <Setter Property="CombineMode" Value="Cluster"/>
  <Setter Property="ShowLabels" Value="True"/>
  <Setter Property="LegendSettings">
    <Setter.Value>
      <telerik:SeriesLegendSettings Title="{Binding Legend}"/>
    </Setter.Value>
  </Setter>
</Style>

Thanks!
Carlos.

2 Answers, 1 is accepted

Sort by
0
Carlos Serrano
Top achievements
Rank 1
answered on 17 Jul 2013, 02:04 PM
I actually found the solution in one of your examples (http://demos.telerik.com/silverlight/#ChartView/BrowsersChart).

For some reason, the LegendSettings property must be bound to "Legend" by means of a simple value converter that creates a new SeriesLegendSettings, like so:

XAML:
<Style x:Key="ChartBarSeriesStyle" TargetType="telerik:BarSeries">
<Setter Property="CombineMode" Value="Cluster"/>
<Setter Property="ShowLabels" Value="True"/>
<Setter Property="LegendSettings" Value="{Binding Legend, Converter={StaticResource LegendSettings}}"/>
</Style>

C#:
public class ChartViewLegendSettingsValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return new SeriesLegendSettings { Title = value.ToString() };
}

public
object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
0
Accepted
Petar Kirov
Telerik team
answered on 18 Jul 2013, 06:11 PM
Hi Carlos,

I am glad to hear that you've managed find the solution. This workaround is actually required because of a limitation in the Silverlight framework.
 
Regards,
Petar Kirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ChartView
Asked by
Carlos Serrano
Top achievements
Rank 1
Answers by
Carlos Serrano
Top achievements
Rank 1
Petar Kirov
Telerik team
Share this question
or