Events in .NET MAUI Segmented Control (SfSegmentedControl)

16 Oct 20251 minute to read

The Segmented Control supports the Tapped, and SelectionChanged events to interact with .NET MAUI Segmented Control

Tapped

A Tapped event occurs, each time a segment tapped.

Below is a list of the arguments:

SelectionChanged

The SelectionChanged event is triggered once the segment is selected in the segmented control. The SelectionChangedEventArgs has the following values, which provide information for the SelectionChanged event.

  • OldIndex
  • NewIndex
  • OldValue
  • NewValue
using Syncfusion.Maui.Buttons;
. . .

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        SfSegmentedControl segmentedControl = new SfSegmentedControl();
        segmentedControl.SelectionChanged += OnSegmentedControlSelectionChanged;
        this.Content = segmentedControl;
    }

    private void OnSegmentedControlSelectionChanged(object sender, Syncfusion.Maui.Buttons.SelectionChangedEventArgs e)
    {
        var newValue = e.NewValue;
        var oldValue = e.OldValue;
        var newIndex = e.NewIndex;
        var oldIndex = e.OldIndex;
    }
}