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

Custom tick labels

1 Answer 246 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 22 Jul 2013, 06:25 PM
Is it possible somehow to bind the Ticks source to a list of strings? For example A, B, C, D, E etc

I want to use the slider to change between different modes rather then just use its numerical values :)

Kind regards
Christopher

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 25 Jul 2013, 03:22 PM
Hello Christopher,

Unfortunately, this is not supported out of the box. However you can bind the ThickTemplate property of the RadSlider control as described in this article. Furthermore, you can use a converter to return the desired strings like this:
XAML
<Window.Resources>
        <local:MyConverter x:Key="Conv"/>
 
    </Window.Resources>
    <Grid>
        <telerik:RadSlider Maximum="10" TickFrequency="1" TickPlacement="Both">
            <telerik:RadSlider.TickTemplate>
                <DataTemplate>
                    <Grid>
                        <TextBlock Text="{Binding Converter={StaticResource Conv}}" FontSize="11"/>
                    </Grid>
                </DataTemplate>
            </telerik:RadSlider.TickTemplate>
        </telerik:RadSlider>
    </Grid>


C#
public class MyConverter : IValueConverter
    {
        #region IValueConverter Members
 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            switch (value.ToString())
            {
                case "0": return "Your first string";
                case "1": return "Your second strig";
//more cases
                default:
                    return "default";
            }
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
 
        #endregion
    }
I hope this will help you.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Slider
Asked by
Christopher
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or