I had to put GroupName at the same level as SelectedValue like this:
<VerticalStackLayout RadioButtonGroup.GroupName="FOO" RadioButtonGroup.SelectedValue="{Binding SelectedThing}">
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I can't get RadioButtonGroup.SelectedValue to bind to a viewmodel property. I've read everything that you can google including:
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;
I'm not sure what else might be relevant.
I had to put GroupName at the same level as SelectedValue like this:
<VerticalStackLayout RadioButtonGroup.GroupName="FOO" RadioButtonGroup.SelectedValue="{Binding SelectedThing}">