Custom tick labels

2 posts, 0 answers
  1. Christopher
    Christopher avatar
    1 posts
    Member since:
    Apr 2013

    Posted 22 Jul 2013 Link to this post

    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
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 25 Jul 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top