Selection changed

26 Jun 2019 / 1 minute to read

The selection changed event occurs when changing from one segment item to another in the segmented control. It can be handled in two ways.

User interface

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

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

  • c#
  • SfSegmentedControl segmentedControl = new SfSegmentedControl();
    segmentedControl.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
    segmentedControl.BorderColor = UIColor.Red;

    Selected index programmatically

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

  • c#
  • SfSegmentedControl segmentedControl = new SfSegmentedControl();
    segmentedControl.SelectedIndex = 2;

    SegmentedControl SelectedIndex in Xamarin.iOS