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

RadHorizontalDataAxis LabelFormat

1 Answer 154 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
jen asked on 19 Feb 2016, 02:46 PM

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



1 Answer, 1 is accepted

Sort by
Telerik team
answered on 24 Feb 2016, 11:53 AM

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
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question