This is expected behavior as you cannot set an index that is out of the available range (the exception should be an OutOfRangeException instead).
To clarify about the -1 value, is the typical default SelectedIndex when nothing is selected. Such is the case when there are no items yet. If you have a view model property two-way
bound to the control, you should always initialize that property to -1
instead of 0. The SegementedControl will change it to 0 after the ItemsSource is set.
mySelectedIndex = -1;
On the other side of things, you should always check the item count before setting an index:
var indexToSet = 5;
(indexToSet > myItems.Count - 1)
indexToSet = myItems.Count - 1;
SelectedIndex = indexToSet;
Although the Xamarin.Forms Picker lets you set an out of bound value, and it shifts to the next available value, this is not the typical behavior of items controls. If there isn't an index available, it should not select an invalid location instead (first or last item).
In any case, I have submitted a feature request to development team to consider adding a Picker-like behavior: SegmentedControl SelectedIndex Bounds
. Please take a moment to up-vote/follow the item and leave a comment if you have any other info you'd like to add.
I hope this info was helpful.
Lance | Tech Support Engineer, Sr.
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Feedback Portal
and vote to affect the priority of the items