Clyde Eisenbeis

Clyde Eisenbeis

  • 1.7k
  • 79
  • 13.5k

How do I uncheck all radio buttons at one time? ... Continued

Dec 2 2024 4:04 PM

c-sharpcorner.com/forums/how-do-i-uncheck-all-radio-buttons-at-one-time

XAML

<GroupBox Name="FirstGroupBox"
            Header="1st"
            Margin="10,0,5,0"
            Height="auto"
            Width="auto"
            >
  <RadioButton x:Name="gRBuResearcher1" Content ="Researcher" Click="gRBuResearcher1_Click" />
  <RadioButton x:Name="gRBuScientist1" Content="Scientist" Click="gRBuScientist1_Click" />
  <RadioButton x:Name="gRBuMedic1" Content="Medic" Click="gRBuMedic1_Click" />
</GroupBox>

XAML.CS

using System.Windows.Controls;

foreach (var child in FirstGroupBox.Children) 
{
    if (child is RadioButton rb)
    {
        rb.IsChecked = false;// Uncheck each RadioButton
    }
}

results in error message "GroupBox does not contain a definition for 'Children' ...." => snipboard.io/9dnwLZ.jpg


Answers (1)