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

Cannot Style the ItemLabelStyle

3 Answers 106 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Sparky
Top achievements
Rank 1
Sparky asked on 15 Aug 2010, 06:42 AM
Hi
I am trying to style the default labels for the Pie Series definition. I used the style given in the documentation (http://www.telerik.com/help/wpf/radchart-styling-and-appearance-styling-item-labels.html) but the style is never applied. I tried several approaches, such as setting the ItemLabelStyle's Style property to x:Null in xaml, in code behind, then re-apply the style both in the initialized and loaded code sections. The system correctly finds the style and its collections of setters etc, but it just does not seem to get applied. I can format the label, but I cannot style it.

The final goal is to template the label with a textbox and a button, and when the user clicks each segment, the textbox is populated with the dataitem of that pie piece, and the user can change the values, click the button and update the segment.

We are going into UAT this week, and this is a major part of our functionality. We would really like to have this functionality as part of our release, so any help in the matter will be deeply appreciated. We are working both with the Q1 sp2 and the Q2 Beta releases.
Thank you so much and keep up the good work with the cool controls.

3 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 18 Aug 2010, 11:08 AM
Hi Sparky,

 I tried to reproduce your scenario and got the Style from the documentation and put it in the Resources of the RadChart. Applying the style both in XAML and in code on OnLoaded event successfully styles the labels.

Style:

         <Style x:Key="myLabelStyle" TargetType="telerik:SeriesItemLabel">
             <Setter Property="HorizontalContentAlignment"
Value="Center" />
             <Setter Property="Padding"
Value="2,0" />
             <Setter Property="IsHitTestVisible"
Value="False" />
             <Setter Property="Foreground"
Value="#FF535353" />
             <Setter Property="FontWeight"
Value="Bold" />
             <Setter Property="FontStyle"
Value="Italic" />
             <Setter Property="FontFamily"
Value="Trebuchet MS" />
             <Setter Property="FontSize"
Value="18.667" />
             <Setter Property="Template">
                 <Setter.Value>
                     <ControlTemplate TargetType="telerik:SeriesItemLabel">
                         <Canvas>
                             <Polyline x:Name="PART_Connector" Style="{TemplateBinding ConnectorStyle}" />
                             <Border x:Name="PART_TextContainer"
                Style="{TemplateBinding LabelStyle}"
                Canvas.Left="{TemplateBinding TextContainerCanvasLeft}"
                Canvas.Top="{TemplateBinding TextContainerCanvasTop}">
                                 <StackPanel Orientation="Horizontal">
                                     <TextBox Margin="{TemplateBinding Padding}"
                       Text="{TemplateBinding Content}"
                       TextAlignment="{TemplateBinding HorizontalContentAlignment}" />
                                     <Button Content="OK" />
                                 </StackPanel>
                             </Border>
                         </Canvas>
                     </ControlTemplate>
                 </Setter.Value>
             </Setter>
         </Style>

Setting it in XAML:
<telerik:SeriesMapping.SeriesDefinition>
    <telerik:PieSeriesDefinition SeriesItemLabelStyle="{StaticResource myLabelStyle}" />
</telerik:SeriesMapping.SeriesDefinition>

Setting it in code behind on OnLoaded event:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
    RadChart1.SeriesMappings[0].SeriesDefinition.SeriesItemLabelStyle = (Style)RadChart1.Resources["myLabelStyle"];
}

Please review the code above and check if it works for you.

Regards,
yivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sparky
Top achievements
Rank 1
answered on 18 Aug 2010, 01:59 PM
Hi Yivanov:
Thanks for the reply. I was using what was in the sample - namely the DefaultSeriesDefinition rather than SeriesMapping[0]. So this seems to be ok for now.
One other question, can you please point me to the section of the documentation where I can get the full listing of the styles used in the chart control? Or is there a way for me to get it so in the future, if I need to style some other subsection, I will have the default style as a reference.
Thanks
~sparky
0
Accepted
Yavor
Telerik team
answered on 19 Aug 2010, 08:34 AM
Hello Sparky,

DefaultSeriesDefinition is used when you don't have your own SeriesDefinition. Then the DefaultSeriesDefinition kicks in. But when you have your own SeriesDefinition (e.g. defined in a SeriesMapping) you must style it separately.
You can find full listing of styles in RadChart here.

Kind regards,
Yavor Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Sparky
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Sparky
Top achievements
Rank 1
Share this question
or