Customize Radial Scale

2 posts, 0 answers
  1. Craig
    Craig avatar
    4 posts
    Member since:
    Feb 2014

    Posted 26 Mar 2014 Link to this post

    Is it possible to customize the Radial Scale in a RadGauge control so that it displays letters (A-F) instead of numbers?
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 27 Mar 2014 Link to this post

    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.

     
  3. DevCraft banner
Back to Top