Horizontal Bar AxisX Label Background Color

2 posts, 0 answers
  1. Arun Kumar
    Arun Kumar avatar
    60 posts
    Member since:
    Nov 2009

    Posted 17 Jul 2011 Link to this post

    Hi all,

    I want to change the background color of AxisX label. I had seen some forums to change the text alignment. But I want to change background color (something like telerik PITS dashboard - Activity). How do I achieve that?
  2. Peshito
    Admin
    Peshito avatar
    496 posts

    Posted 20 Jul 2011 Link to this post

    Hello Arun Kumar,

    Thanks for contacting us.

    Changing the labels background is not supported out of the box. In order to achieve that, additional retemplating needs to be done.

    I've attached a sample project that you could refer to and see how I did it.

    If you simply want to change the labels' foreground only, it can be done easily by creating a new style like this:
    </UserControl.Resources>
    <Style x:Key="LabelForeground" TargetType="TextBlock">
                <Setter Property="Foreground" Value="Red" />
    </Style>
    </UserControl.Resources>


    and then show in your code behind what style should be used:
    lineChart.DefaultView.ChartArea.AxisX.AxisStyles.ItemLabelStyle = this.Resources["ItemLabelStyle"] as Style;

    In case you haven't visited our Styes and Templates help topics, they can be found here.

    Best wishes,
    Peshito
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
Back to Top