How to group .NET MAUI RadioButton(SfRadioButton)?
This section explains how to group .NET MAUI RadioButton. Grouping RadioButtons ensures that only one option can be selected within a group, which is useful for providing users with choices between different categories.
Step 1: Define SfRadioGroupKey Resources
Define a RadioGroupKey element inside the ContentPage.Resources section to group your RadioButtons. In the example below, I define two RadioGroupKey with keys, “carBrand” and “bikeBrand”, to organize RadioButtons associated with car and bike brands, respectively.
XAML
<contentpage.resources>
<buttons:sfradiogroupkey x:key="carBrand">
<buttons:sfradiogroupkey x:key="bikeBrand">
</buttons:sfradiogroupkey></buttons:sfradiogroupkey></contentpage.resources>
Step 2: Create RadioButtons and Assign GroupKey
Create the RadioButton controls within a StackLayout and assign the appropriate GroupKey to each RadioButton. This ensures that the RadioButtons are grouped correctly, allowing only one selection per group.
XAML
<stacklayout>
<buttons:sfradiobutton text="Honda" groupkey="{StaticResource carBrand}">
<buttons:sfradiobutton text="Hyundai" groupkey="{StaticResource carBrand}">
<buttons:sfradiobutton text="Volkswagen" groupkey="{StaticResource carBrand}">
<buttons:sfradiobutton text="Yamaha" groupkey="{StaticResource bikeBrand}">
<buttons:sfradiobutton text="Bajaj" groupkey="{StaticResource bikeBrand}">
</buttons:sfradiobutton></buttons:sfradiobutton></buttons:sfradiobutton></buttons:sfradiobutton></buttons:sfradiobutton></stacklayout>
Output
Conclusion
I hope you enjoyed learning how to group the .NET MAUI RadioButton.
You can refer to our .NET MAUI RadioButton feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI RadioButton documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI RadioButton and other .NET MAUI components.
Please let us know in the following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct - Trac, or feedback portal. We are always happy to assist you!