Articles in this section

How to clear the Segment selection in the .NET MAUI Segmented Control (SfSegmentedControl)?

In the Syncfusion® .NET MAUI Segmented Control, you can clear the segment selection by following the demonstration below.

XAML:

Initialize the SfSegmentedControl and set the ItemsSource as demonstrated in the following code:

<buttons:SfSegmentedControl x:Name="segment"
                           HeightRequest="40"
                           SelectedIndex="1">
   <buttons:SfSegmentedControl.ItemsSource>
       <x:Array Type="{x:Type x:String}">
           <x:String>Day</x:String>
           <x:String>Week</x:String>
           <x:String>Month</x:String>
           <x:String>Year</x:String>
       </x:Array>
   </buttons:SfSegmentedControl.ItemsSource>
</buttons:SfSegmentedControl>

C#:

In the ButtonClicked event, set the SelectedIndex of the segment as “-1” to clear the segment selection.

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

Download the complete sample from GitHub.

Output:

ClearSegmentSelection.gif

Conclusion:

I hope you enjoyed learning how to clear the segment selection in the .NET MAUI Segmented Control (SfSegmentedControl).

Refer to our .NET MAUI Segmented Control feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Segmented Control documentation to understand how to present and manipulate data.

Check out our .NET MAUI components from the License and Downloads page for current customers. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Segmented Control and other .NET MAUI components.

Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-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)
Access denied
Access denied