3D Axis Label Styling

2 posts, 0 answers
  1. Richard Alvarez
    Richard Alvarez avatar
    11 posts
    Member since:
    May 2005

    Posted 28 Apr 2011 Link to this post

    I'm trying to style the axis labels, in accordance with the code here (http://www.telerik.com/help/silverlight/radchart-styling-and-appearance-styling-axis-item-label.html), but without a xaml style reference.  In my code-behind, I have this...

    Style style = new Style(typeof(TextBlock));
    style.Setters.Add(new Setter(TextBlock.FontSizeProperty, 5));
    chart.DefaultView.ChartArea.AxisX.AxisStyles.ItemLabelStyle = style;

    But, it's not doing anything to the appearance.  This is for a 3D line chart.  Do I need a different type in the setter?
  2. Yavor
    Yavor avatar
    401 posts

    Posted 04 May 2011 Link to this post

    Hello Richard Alvarez,

    Styling 3D charts is a little bit different than styling 2D. 3D charts use different templates, styles and controls. Currently styling a 3D series type can be done by using implicit styles or setting the style directly on the element from code behind.

    First create your style with target type Label3D (this is the type for 3D labels) like this:

    private Style CreateStyle()
        Style style = new Style(typeof(Label3D));
        style.Setters.Add(new Setter(Label3D.FontSizeProperty, 5));
        return style;

    Next hook up to the ChartArea Loaded event and apply the style to the axis labels like this:
    public SilverlightControl12()
        this.ProductChart.DefaultView.ChartArea.Loaded += new RoutedEventHandler(ChartArea_Loaded);
    void ChartArea_Loaded(object sender, RoutedEventArgs e)
        ChartArea area = sender as ChartArea;
        var axisLabels = area.ChildrenOfType<LayoutTransformControl>();
        Style style = CreateStyle();
        foreach (var item in axisLabels)
            item.FindChildByType<Label3D>().Style = style;

    Axis labels are wrapped in LayoutTransformControl because they can be rotated. This separates them from the series item labels that are added only as Label3D objects. Feel free to modify the code above as you please.

    Hope this helps!

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