Borrowing (yet again) my VisualTreeEnumeration from this answer (I really really need to blog):-
public static class VisualTreeEnumeration
{
public static IEnumerable<DependencyObject> Descendents(this DependencyObject root)
{
int count = VisualTreeHelper.GetChildrenCount(root);
for (int i=0; i < count; i++)
{
var child = VisualTreeHelper.GetChild(root, i);
yield return child;
foreach (var descendent in Descendents(child))
yield return descendent;
}
}
}
Place this in a file in either your main namespace or in a utility namespace that you place a using
for in your code.
Now you can use LINQ to get all sorts of useful lists. In your case:-
List<RadioButton> group = this.Descendents()
.OfType<RadioButton>()
.Where(r => r.GroupName == "MyGroupName")
.ToList();