-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
area-controls-radiobuttonRadioButton, RadioButtonGroupRadioButton, RadioButtonGroupdelighterplatform/androidplatform/iosplatform/macosmacOS / Mac CatalystmacOS / Mac Catalystplatform/windowss/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Milestone
Description
Description
<StackLayout Margin="10"
RadioButtonGroup.GroupName="{Binding GroupName}"
RadioButtonGroup.SelectedValue="{Binding Selection}">
<Button Command="{Binding ResetCommand}" Text="Reset" />
<Label Text="What's your favorite animal?" />
<RadioButton Content="Cat" Value="Cat" />
<RadioButton Content="Dog" Value="Dog" />
<RadioButton Content="Elephant" Value="Elephant" />
<RadioButton Content="Monkey" Value="Monkey" />
<Label x:Name="animalLabel">
<Label.FormattedText>
<FormattedString>
<Span Text="You have chosen:" />
<Span Text="{Binding Selection}" />
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>public class AnimalViewModel : INotifyPropertyChanged
{
string groupName;
object selection;
public AnimalViewModel()
{
ResetCommand = new Command(() =>
{
Selection = null;
});
}
public string GroupName
{
get => groupName;
set
{
groupName = value;
OnPropertyChanged(nameof(GroupName));
}
}
public object Selection
{
get => selection;
set
{
selection = value;
OnPropertyChanged(nameof(Selection));
}
}
public ICommand ResetCommand { get; private set; }
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}When Selection is set to null an animal stays checked. It should remove the checked state. If the Value of the RadioButton is not equal to the RadioButtonGroup.SelectedValue.
After SelectedValue is set to null:

Steps to Reproduce
No response
Link to public reproduction project repository
Used this repo to add a ResetButton to the GroupedRadioButtonsViewModelPage sample page
https://github.com/dotnet/maui-samples/tree/main/8.0/UserInterface/Views/RadioButtonDemos
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
net8.0-windows10.0.19041.0
Did you find any workaround?
I've put this code in the code behind file of the view.
vm.PropertyChanged += (s, e) =>
{
if (e.PropertyName == nameof(vm.SelectedCountryCode))
{
if (vm.SelectedCountryCode == null)
{
foreach (var child in this.Countries.Children)
{
if (child is RadioButton radioButton)
{
radioButton.IsChecked = false;
}
}
}
}
};Relevant log output
No response
peruchali
Metadata
Metadata
Assignees
Labels
area-controls-radiobuttonRadioButton, RadioButtonGroupRadioButton, RadioButtonGroupdelighterplatform/androidplatform/iosplatform/macosmacOS / Mac CatalystmacOS / Mac Catalystplatform/windowss/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
