Skip to content

Segmented Button

A segmented control is a linear set of two or more segments, each of which functions as a mutually exclusive button. Within the control, all segments are equal in width.

Segmented Control

Like buttons, segments can contain text or images. Segmented controls are often used to display different views. In Maps, for example, a segmented control lets you switch between Map, Transit, and Satellite views.

The segmented button is an instance of the UISegmentedControl class.

Configuring segmented control

The following properties can be configured in the story board:

Segmented control properties

Handle value changed event

You can also wire up the ValueChanged event from the story board as follows:

Segmented Control Valued Changed Event

and adding the method in the view controller code as follows:

1
2
3
4
5
partial void HandleSegmentedChanged(UISegmentedControl sender)
{
    var title = sender.TitleAt(sender.SelectedSegment);
    Debug.WriteLine(title);
}

or you can wire up the event in code as follows :

1
2
3
4
5
6
7
8
public override void ViewDidLoad()
{
    base.ViewDidLoad();
    mapOptions.ValueChanged += (sender, e) => {
        var title = mapOptions.TitleAt(mapOptions.SelectedSegment);
    };

}