How to Customize the .NET MAUI Radio Buttons?
The .NET MAUI RadioButton allows you to group a set of radio buttons using the .NET MAUI RadioGroup and .NET MAUI RadioGroupKey.
To create a rounded rectangle Radio Button, place the Radio Button within a Border. However, maintaining the group selection of rounded rectangle radio buttons using RadioGroup can disrupt the internal layout and event handling mechanisms because the SfRadioGroup expects direct child SfRadioButton elements for proper management. Therefore, use the SfRadioGroupKey to maintain the group selection for rounded rectangle radio buttons.
XAML:
<ContentPage.Resources>
<Style x:Key="SettingsRoundRect" TargetType="Border">
<Setter Property="WidthRequest" Value="300"/>
<Setter Property="StrokeShape" Value="RoundRectangle 10"/>
</Style>
</ContentPage.Resources>
<StackLayout>
<buttons:SfRadioGroupKey x:Name="RadioGroupKey" Spacing="5" >
<Border Style="{StaticResource SettingsRoundRect}">
<buttons:SfRadioButton Text="Style 1" Value="1" GroupKey="{Binding Source={x:Reference RadioGroupKey}}"/>
</Border>
<Border Style="{StaticResource SettingsRoundRect}" >
<buttons:SfRadioButton Text="Style 2" Value="2" GroupKey="{Binding Source={x:Reference RadioGroupKey}}"/>
</Border>
<Border Style="{StaticResource SettingsRoundRect}" >
<buttons:SfRadioButton Text="Style 3" Value="3" GroupKey="{Binding Source={x:Reference RadioGroupKey}}"/>
</Border>
</buttons:SfRadioGroupKey>
</StackLayout>
Output:
Download the complete sample from the GitHub.
Conclusion
I hope you enjoyed learning how to customize .NET MAUI Radio Buttons.
You can refer to our .NET MAUI RadioButton feature tour page to learn about its other groundbreaking features. Additionally, explore the .NET MAUI RadioButton documentation to quickly get started with 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 forums, Direct-Trac or feedback portal. We are always happy to assist you!