Custom lables for Min/Max in SfSlider

Hello,

Is it possible to have the SfSlider show different lables only on first and last ticks? 
for example if Minimum is 0 and Maximum is 10 I want the label to show "Very slow" for 0 and "Super fast" for 10, all other ticks should be labled from 2 throughout 9


Thank you


1 Reply 1 reply marked as answer

NT Nitheeshkumar Thangaraj Syncfusion Team September 6, 2023 09:30 AM UTC

Hi Mohammed,


With the input you provided, we would like to inform you that your requirement has been successfully achieved using the LabelCreated event to customize the label text. The code snippet and image are provided below.


<slider:SfSlider ShowLabels="True" Minimum="0" Maximum="10"  Value="5" ShowTicks="True"

LabelCreated="SfSlider_LabelCreated"/>                    


private void SfSlider_LabelCreated(object sender, SliderLabelCreatedEventArgs e)

    {

         if (sender is SfSlider minSlider)

        {

            if (minSlider.Minimum.ToString() == e.Text)

            {

e.Text = "Very Slow";

            }

            if (minSlider.Maximum.ToString() == e.Text)

            {

e.Text = "Very Fast";

            }

        }   

}



We hope this solution aligns with your needs. If you have any more questions or require further assistance, please feel free to ask.



Regards,

Nitheeshkumar.


Marked as answer
Loader.
Up arrow icon