Change color of axis labels and lines

4 posts, 0 answers
  1. David
    David avatar
    7 posts
    Member since:
    Jun 2009

    Posted 24 Jan 2012 Link to this post

    Is it possible to change the color of the axis labels and the axis lines? I have a DateTimeContinuousAxis and a LinearAxis and I cant seem to change the colors from the default Black.


    thanks
  2. Sia
    Admin
    Sia avatar
    667 posts

    Posted 27 Jan 2012 Link to this post

    Hi,

    Please set the following style:
    <Style x:Key="CustomAxis" TargetType="telerik:Axis">
        <Setter Property="LineStroke" Value="Red" />
        <Setter Property="LabelStyle">
            <Setter.Value>
                <Style TargetType="TextBlock">
                    <Setter Property="Margin" Value="4"/>
                    <Setter Property="Foreground" Value="Red" />
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="MajorTickStyle">
            <Setter.Value>
                <Style TargetType="Rectangle">
                    <Setter Property="Fill" Value="Red"/>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>

    to the axes in your application.

    All the best,
    Sia
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Jorge
    Jorge avatar
    6 posts
    Member since:
    Oct 2011

    Posted 29 Feb 2012 Link to this post

    Hi, how could I change the color of an axis title? I guess it is using the TitleTemplate property, but I don't know how to define it.
  5. Sia
    Admin
    Sia avatar
    667 posts

    Posted 02 Mar 2012 Link to this post

    Hi Jorge,

    Yes, the TitleTemplate can be used for such purpose through the same style.

    Here it is:
    <Style x:Key="CustomAxis" TargetType="telerik:Axis">
        <Setter Property="TitleTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{Binding}" Foreground="Orange" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    Greetings,
    Sia
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top