Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Slider > Ticks & Thumb questions

Answered Ticks & Thumb questions

Feed from this thread
  • Nicolas avatar

    Posted on Apr 9, 2010 (permalink)

    Hello,
    First, thanks for making such a great library! I saved many hours by using the WPF controls.
    I am working with the Slider with Selection Range enabled at the moment.
    My slider should start at -12 and end at 0. This range can change, but will remain from a negative value to 0.
    I would like the tick marks to be set every 4 units for instance, but I want the slider to increase or decrease by one only. Do you have any tip on how to achieve such behavior?
    I would like also to lock the position of a thumb in a range slider, is that possible?
    Thanks in advance for your support.

    Reply

  • Answer Tina Stancheva Tina Stancheva admin's avatar

    Posted on Apr 13, 2010 (permalink)

    Hi Nicolas Bastin,

    RadSlider supports the functionality of having two thumbs, thus enabling range selection. To enable the selection range you have to set the IsSelectionRangeEnabled property to true. Modifying the range can be done via two additional properties - SelectionStart and SelectionEnd. However, when a selection range is enabled, there cannot be another thumb in the range.

    RadSlider's properties - LargeChange and SmallChange allow you to define the amount of value that will be used as a step-size. Setting LargeChange, for example, will control how much the thumb will travel when the track is clicked. SmallChange on the other hand is used when RadSlider has its handles visible. Clicking any of the handles will increase/decrease the value by the amount specified in SmallChange.

    The TickFrequency property allows you to place marks(ticks) along the track in a uniform manner.
    When the IsSnapToTickEnabled property is set to true and you drag the thumb, click the handles or simply click the track, then the thumb snaps to the nearest tick.

    However, if you need to display ticks on every 4 units but still have a step-size of 1, what you can use is a TickTemplateSelector.  It allows you to define your own logic controlling how the ticks can be displayed.

    public class TickTemplateSelector : DataTemplateSelector
        {
            public DataTemplate EllipseTemplate { get; set; }
            public DataTemplate EmptyTemplate { get; set; }
     
            public override DataTemplate SelectTemplate(object item, DependencyObject container)
            {
                double tick = Convert.ToDouble(item);
                if (tick % 4 == 0.0)
                {
                    return EllipseTemplate;
                }
                else
                {
                    return EmptyTemplate;
                }
            }
        }

    I have prepared an example for you, demonstrating how to use the described properties to implement the scenario you described. Please take a look at it and let me know if you need more info.

    Sincerely yours,
    Tina Stancheva
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
    Attached files

    Reply

  • Nicolas avatar

    Posted on Apr 13, 2010 (permalink)

    Thank you Tina! I didn't think of the template selector, but it really solves my problem!

    Reply

  • Nicolas avatar

    Posted on Nov 8, 2010 (permalink)

    Hello,
    How come the container parameter is null?
    I would like to access the RadSlider Maximum and Minimum to know if I should make the tick visible or not.
    If in your example I change the Tick Template from an Ellipse to a TextBox, I have some strange behaviour, can you make sure it's working for you?
    Regards

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Nov 9, 2010 (permalink)

    Hello Nicolas Bastin,

    Thank you for your cooperation. This appears to be a bug in the RadSlider. However, we fixed it and the fix will be included in the Q3 2010 official release of the Telerik controls later this week. I updated your Telerik points accordingly.

    Please let us know if you need more info and we would be glad to assist you.

    Greetings,
    Petar Mladenov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Slider > Ticks & Thumb questions
Related resources for "Ticks & Thumb questions"

WPF Slider Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]