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

Customize Radial Scale

1 Answer 64 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 26 Mar 2014, 05:50 PM
Is it possible to customize the Radial Scale in a RadGauge control so that it displays letters (A-F) instead of numbers?

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 27 Mar 2014, 04:58 PM
Hello Craig,

You can customize labels on the scale using a custom LabelTemplate with a custom value converter for the label value.
Please find a possible sample code below.
<Window x:Class="CustomLabels.MainWindow"
        xmlns:local="clr-namespace:CustomLabels"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <local:CustomLabelConverter x:Key="CustomLabelConverter" />
    </Window.Resources>
    <Grid>
        <telerik:RadRadialGauge>
            <telerik:RadialScale x:Name="scale"
                                 Min="0" Max="15"
                                 MajorTickStep="1">
                <telerik:RadialScale.LabelTemplate>
                    <DataTemplate>
                        <TextBlock HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               FontFamily="{Binding FontFamily}"
                               FontSize="{Binding FontSize}"
                               FontStretch="{Binding FontStretch}"
                               FontStyle="{Binding FontStyle}"
                               FontWeight="{Binding FontWeight}"
                               Foreground="{Binding Foreground}"
                               Text="{Binding Converter={StaticResource CustomLabelConverter}}" />
                    </DataTemplate>
                </telerik:RadialScale.LabelTemplate>
            </telerik:RadialScale>
        </telerik:RadRadialGauge>
    </Grid>
</Window>
using System;
using System.Windows;
using System.Windows.Data;
using Telerik.Windows.Controls.Gauge;
 
namespace CustomLabels
{
    public class CustomLabelConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double labelValue = ScaleObject.GetValue(value as DependencyObject);
            string hexValue = string.Format("{0:X}", (int)labelValue);
 
            return hexValue;
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

Regards,
Andrey Murzov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Gauge
Asked by
Craig
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or