Notify the selection changes in SfSegmentedControl in Xamarin.Android

3 Sep 20201 minute to read

The segmented control handles the Selection changed when there is a change from one segment item to another. It can be handled by two ways.

User interface

When users navigate from one item to another, selection is changed, so that the SelectedIndex value is updated to the new index of the item. The segmented control provides the SelectionChanged event, which is triggered when the selection is changed with the SelectionChangedEventArgs.

Index - Gets the current index value of the selected item.

  • C#
  • segmentedControl.SelectionChanged += (object sender, SelectionChangedEventArgs e) => 
    {
        var selectedIndex = e.Index;
    };

    Selected Index through programmatically.

    You can set the default value programmatically for the selection to be placed. The selection gets updated based on the index value given for the SelectedIndex.

  • C#
  • segmentedControl.SelectedIndex = 2;

    Xamarin.Android SfSegmentedControl with selection of second item