Events in .NET MAUI Slider (SfSlider)

14 Apr 20225 minutes to read

This section explains about how to add the events for slider.

Handle callbacks

  • ValueChangeStart - Called when the user selecting a new value for the slider by tap/mouse down in the thumb.
  • ValueChanging - Called when the user is selecting a new value for the slider by dragging the thumb.
  • ValueChanged - Called when the user completed selecting a new value.
  • ValueChangeEnd - Called when the user stopped interacting with slider by tap/mouse up the thumb.
<sliders:SfDateTimeSlider  Minimum="2010-01-01" 
   SfDateTimeSlider slider = new SfDateTimeSlider();
   slider.Minimum = new Date(2010, 01, 01);
   slider.Maximum = new Date(2020, 01, 01);
   slider.value = new Date(2014, 01, 01);
   slider.ValueChangeStart += OnValueChanged;
   slider.ValueChanging += OnValueChanged;
   slider.ValueChanged += OnValueChanged;
   slider.ValueChangeEnd += OnValueChanged;

private void OnValueChangeStart(object sender, EventArgs e)

private void OnValueChanging(object sender, SliderValueChangingEventArgs e)

private void OnValueChanged(object sender, SliderValueChangedEventArgs e) 
private void OnValueChangeEnd(object sender, EventArgs e)

Customize label text

You can format or change the whole numeric or date label text using the LabelCreated event. The SliderLabelCreatedEventArgs contains the following parameters,

  • Text – Customize the text color using the Text parameter.
  • Style – Formats the text color, font size, font family, offset using the Style parameter.
<sliders:SfSlider Minimum="2" 
   SfSlider slider = new SfSlider();
   slider.Minimum = 2;
   slider.Maximum = 10;
   slider.Value = 6;
   slider.Interval = 2;
   slider.ShowLabels = true;
   sfslider.LabelCreated += OnLabelCreated;

 private void OnLabelCreated(object sender, SliderLabelCreatedEventArgs e)
   e.Text = "$" + e.Text;

Slider custom label

Tooltip text format

By default it is formatted based on NumberFormat property and DateFormat property based on whether it is date type SfDateTimeSlider or numeric SfSlider.

You can format or change the whole tooltip label text using the TooltipLabelCreated event. The SliderTooltipLabelCreatedEventArgs contains the following parameters,

  • Text – Change the format of the tooltip text using the Text property.
  • Style – Change the appearance of the tooltip text like color, stroke color, and padding using the Style property.
      <slider:SliderTooltip TooltipLabelCreated="OnTooltipLabelCreated"/>
   SfSlider slider = new SfSlider();
   slider.TooltipLabelCreated += OnTooltipLabelCreated;

private void OnTooltipLabelCreated(object sender, SliderTooltipLabelCreatedEventArgs e)
    e.Text = "$" + e.Text;

Slider custom tooltip