c-sharpcorner.com/forums/how-do-i-uncheck-all-radio-buttons-at-one-time
XAML
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
Muhammad Imran AnsariPosted Dec 2, 2024, 6:20 PM
Hi Clyde,
The error occurs because
GroupBoxdoes not have aChildrenproperty directly. Instead, theGroupBoxtypically contains a single child element, which is often aPanel(likeStackPanel,Grid, etc.). To access the radio buttons, you need to first access the child panel within theGroupBox, then iterate over the elements in that panel. Here is the updated code but you can use the the element accordingly:XAML.CS
Thank you!