Добавьте этот класс в свой проект: -
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;
}
}
}
Теперь вы можете использовать этот код: -
List<MyCustomControl> = this.Descendents().OfType<MyCustomControl>().ToList();