You can define custom slider items for the RadSlider control and add them to the RadSlider's Items collection. As a result, the behavior of the slider changes - the items in the Items collection define the possible values for the slider. The Value, SelectionStart and SelectionEnd properties of the slider in this case represent the index in the Items collection of the currently selected slider item(s). Each slider item exposes the following properties:
-
Text - sets the text that the slider item displays
-
Value - sets the value of the slider item
-
ToolTip - sets the tooltip of the slider item
-
CssClass - sets the CSS class that is applied to the slider item
You can access the currently selected item(s) using the following properties:
-
SelectedItem - for a slider with IsSelectionRangeEnabled set to
false. As the Value property of the slider in this case represents
the index of the selected item, you can use the following code to get a reference to the selected slider item as well:
RadSliderItem selectedItem = RadSlider1.Items[RadSlider1.Value];
-
SelectedItems - for a slider with IsSelectionRangeEnabled set to true.
As the SelectionStart and SelectionEnd properties of the slider in this case represent the
indices of the selected items, you can use the following code to get a reference to the selected slider items:
RadSliderItem selectedItem1 = RadSlider1.Items[RadSlider1.SelectionStart];
RadSliderItem selectedItem2 = RadSlider1.Items[RadSlider1.SelectionEnd];