RadHorizontalDataAxis LabelFormat

2 posts, 0 answers
  1. jen
    jen avatar
    77 posts
    Member since:
    Jun 2009

    Posted 19 Feb 2016 Link to this post

    I am trying to set the LabelFormat on a RadHorizontalDataAxis, but everything I try turns out to be in the wrong format.

        <telerik:RadHorizontalDataAxis  Minimum="-30"  Maximum="50" LabelsVisibility="FirstLastAndOriginValueOnly" />

    I want the labels to display as  " -30%   0%    50% "

    I have tried setting the string in xaml, and in the loaded event (a binding won't work for me because of where it is in the visual tree)

    LabelFormat = "{0}%" - invalid format

    LabelFormat = "/{0/}/%"- invalid format

    LabelFormat = "P" - applies a calculation "-300.000%  0.000% 500.000%" which I could work around, if there is a way to hide the decimals?


    Can anyone help me out? None the formatting examples ever seem to show how to set stringformats in xaml with the proper characters escapes



  2. Peshito
    Peshito avatar
    524 posts

    Posted 24 Feb 2016 Link to this post


    If I understood you correctly what you are trying to achieve is to only add the "%" symbol at the end of the axis values. If that so, you could take advantage of the axis' LabelTemplate property along with a converter in order to concatenate the symbol at the end of the axis label value.
    For example:
                <TextBlock Text="{Binding Converter={StaticResource converter}}" />
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        return (string)value + "%";

    Hope this helps.

    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 Feedback Portal and vote to affect the priority of the items
Back to Top