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

Ticks & Thumb questions

4 Answers 201 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 09 Apr 2010, 09:55 AM
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.

4 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 13 Apr 2010, 09:34 AM
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.
0
Nicolas
Top achievements
Rank 1
answered on 13 Apr 2010, 10:01 AM
Thank you Tina! I didn't think of the template selector, but it really solves my problem!
0
Nicolas
Top achievements
Rank 1
answered on 08 Nov 2010, 03:29 PM
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
0
Petar Mladenov
Telerik team
answered on 09 Nov 2010, 04:39 PM
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
Tags
Slider
Asked by
Nicolas
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Nicolas
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or