RadCartesianChart with SeriesProvider, binding on Title on SeriesLegendSettings not working

3 posts, 1 answers
  1. Carlos Serrano
    Carlos Serrano avatar
    12 posts
    Member since:
    May 2010

    Posted 16 Jul 2013 Link to this post

    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. Carlos Serrano
    Carlos Serrano avatar
    12 posts
    Member since:
    May 2010

    Posted 17 Jul 2013 Link to this post

    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();
    }
    }
  3. DevCraft banner
  4. Answer
    Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 18 Jul 2013 Link to this post

    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 >>
Back to Top