.NET MAUI RadioButtonGroup.SelectedValue does not work

Crowcoder 50 Reputation points
2025-01-04T22:11:20.1466667+00:00

I can't get RadioButtonGroup.SelectedValue to bind to a viewmodel property. I've read everything that you can google including:

https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/radiobutton?view=net-maui-9.0#respond-to-a-property-change

https://github.com/dotnet/maui-samples/blob/main/9.0/UserInterface/Views/RadioButtonDemos/RadioButtonDemos/Views/GroupedRadioButtonsViewModelPage.xaml

and other questions asked here.

I have made a simplified example to eliminate extraneous issues. I don't get it, it should work and it should be simple based on documentation.

View

   ...
<Grid>
       <ScrollView >
           <VerticalStackLayout HorizontalOptions="Center" Padding="20,0,20,0" >
               <Label Text="Select the course:"></Label>
               <VerticalStackLayout RadioButtonGroup.SelectedValue="{Binding SelectedThing}">
                   <RadioButton GroupName="FOO" Content="ONE" Value="1"></RadioButton>
                   <RadioButton GroupName="FOO" Content="TWO" Value="2" ></RadioButton>
                   <RadioButton GroupName="FOO" Content="THREE" Value="3"></RadioButton>
               </VerticalStackLayout>
               <Label Text="{Binding SelectedThing, StringFormat='The selection is: {0} (not working!)'}"></Label>
...

ViewModel

(based on mvvm toolkit ObservableObject)

 [ObservableProperty]
 private object selectedThing;

User's image

I'm not sure what else might be relevant.

Developer technologies | .NET | .NET MAUI
Developer technologies | XAML
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Crowcoder 50 Reputation points
    2025-01-05T14:12:33.8333333+00:00

    I had to put GroupName at the same level as SelectedValue like this:

    <VerticalStackLayout RadioButtonGroup.GroupName="FOO" RadioButtonGroup.SelectedValue="{Binding SelectedThing}">

    0 comments No comments

  2. Harry Vo (WICLOUD CORPORATION) 1,085 Reputation points Microsoft External Staff
    2025-08-13T03:58:13.5866667+00:00

    Hi @Crowcoder ,

    My name is Harry, Support Engineer who specialize in UWP and MAUI. Thank you for reaching out on Microsoft Q&A!

    I'm sorry to bother you, especially since you already know the cause of your issue. I'm sharing this answer to help others who might encounter the same problem can understand the issue.

    In .NET MAUI, RadioButtonGroup is a feature that allows you to group multiple RadioButton controls together so that only one can be selected at a time. The SelectedValue property is used to bind the selected option to a property in your ViewModel, making it easy to track user choices in an MVVM-friendly way.

    The problem in your original setup was that the GroupName was applied individually to each RadioButton, while the SelectedValue was set on the container (like VerticalStackLayout). For the binding to work correctly, both GroupName and SelectedValue need to be declared at the same level—on the container that wraps the RadioButton elements. Once you moved the GroupName to the container alongside SelectedValue, the binding worked as expected.

    Here is the full correction of your code:

    <VerticalStackLayout 
    	RadioButtonGroup.SelectedValue="{Binding SelectedThing}" 
    	RadioButtonGroup.GroupName="FOO">
    	<RadioButton Content="ONE" Value="1"></RadioButton> 
    	<RadioButton Content="TWO" Value="2" ></RadioButton> 
    	<RadioButton Content="THREE" Value="3"></RadioButton> 
    </VerticalStackLayout>
    

    You can read this documentation to learn more. Thank you!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.