Articles in this section
Category / Section

How to clear the segment selection in Xamarin.Forms SegmentedControl?

1 min read

Xamarin.Forms SegmentedControl allows you to programmatically clear the selection by applying the negative value to the SelectedIndex.

 

Consider the use case to reset the segment selection by clicking the button as follows,

 

 [XAML]

 

..
        <buttons:SfSegmentedControl 
                x:Name="segment"
                SelectionTextColor="White"
                HeightRequest="80"
                VisibleSegmentsCount="6"
                Color="Transparent" 
                BorderColor="Black"
                SelectedIndex="1"
                FontColor="Black"
                BackgroundColor="Transparent" >
            <segmentCollection:List x:TypeArguments="x:String">
                <x:String>RedMi</x:String>
                <x:String>oppo</x:String>
                <x:String>vivo</x:String>
                <x:String>ipad</x:String>
                <x:String>realme</x:String>
                <x:String>Nokia</x:String>
            </segmentCollection:List>
        </buttons:SfSegmentedControl>
        <Button Text="Button" Clicked="Button_Clicked" WidthRequest="150"/>
..

[C#]

 

private void Button_Clicked(object sender, EventArgs e)
        {
            segment.SelectedIndex = -1;
        }

Output


Reset the selection in Xamarin.Forms segmented control

See Also

 

How to add images in the Xamarin.Forms SegmentedControl

How to create a SegmentedControl with custom view

How to customize the segmented item with custom font

 

Conclusion

I hope you enjoyed learning about how to clear the segment selection in Xamarin.Forms SegmentedControl.

You can refer to our Xamarin.Forms SegmentedControl feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied