Accessing LineSeries LabelDefinitions inside CategoricalSeriesDescriptor

3 posts, 1 answers
  1. Sivakumar
    Sivakumar avatar
    27 posts
    Member since:
    Dec 2015

    Posted 13 Mar Link to this post

    I am trying to provide custom label definition for dynamic line series.I could not set access LabelDefinitions for line series type  inside CategoricalSeriesDescriptor.Style . Can you please suggest how to do it ? 
    <telerik:RadCartesianChart.SeriesProvider>
        <telerik:ChartSeriesProvider Source="{Binding YourData}">
            <telerik:ChartSeriesProvider.SeriesDescriptors>
                <telerik:CategoricalSeriesDescriptor ItemsSourcePath="YourData" ValuePath="Value" CategoryPath="Category">
                    <telerik:CategoricalSeriesDescriptor.Style>
                        <Style TargetType="telerik:LineSeries">
                            <Setter Property="LabelDefinitions">
                                <Setter.Value>
                                    <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Center" >
                                        <telerik:ChartSeriesLabelDefinition.Template>
                                            <DataTemplate>
                                                <TextBlock Foreground="DarkBlue" Text="{Binding DataItem.Value}" />
                                            </DataTemplate>
                                        </telerik:ChartSeriesLabelDefinition.Template>
                                    </telerik:ChartSeriesLabelDefinition>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </telerik:CategoricalSeriesDescriptor.Style>
                </telerik:CategoricalSeriesDescriptor>
            </telerik:ChartSeriesProvider.SeriesDescriptors>
        </telerik:ChartSeriesProvider>
    </telerik:RadCartesianChart.SeriesProvider>
  2. Answer
    Martin
    Admin
    Martin avatar
    1099 posts

    Posted 16 Mar Link to this post

    Hi Sivakumar,

    You cannot set LabelDefinitions collection through style because it is read-only. In order to add labels definitions you can use an attached property to set the definition and in the OnPropertyChangedCallback push it in the LabelDefinitions of the series. You can find this approach demonstrated in the Label Template Customization example.

    Regards,
    Martin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Sivakumar
    Sivakumar avatar
    27 posts
    Member since:
    Dec 2015

    Posted 16 Mar in reply to Martin Link to this post

    Thanks Martin...It is working..
Back to Top