XAML
C#
XAML.CS
C#
using System.Windows.Controls;
foreach (var child in FirstGroupBox.Children)
{
if (child.Content is "Scientist")
{
RadioButton.IsChecked = true;
}
}This does not work. How do I set gRBuScientist1 to true?
XAML
XAML.CS
using System.Windows.Controls;
foreach (var child in FirstGroupBox.Children)
{
if (child.Content is "Scientist")
{
RadioButton.IsChecked = true;
}
}This does not work. How do I set gRBuScientist1 to true?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh KumarRank #91 · 22.9K reputationPosted Dec 3, 2024, 7:36 PM EST
Hello,
Please use StackPanel as below, then it should work,
Add StackPanel in you group box,
using System.Linq; using System.Windows.Controls; if (FirstGroupBox.Content is StackPanel stackPanel) { foreach (var child in stackPanel.Children.OfType()) { if (child.Content.ToString() == "Scientist") { child.IsChecked = true; break; } } }