How to get all the Controls/UIElements which are nested in a Tabitem (from a TabControl)?
I tried everything but wasn\'t able to get them.
(Set the SelectedT
for me VisualTreeHelper.GetChildrenCount always returns 0 for tab control, I had to use this method instead
public static List ObtenerControles(DependencyObject parent)
where T : DependencyObject
{
List result = new List();
if (parent != null)
{
foreach (var child in LogicalTreeHelper.GetChildren(parent))
{
var childType = child as T;
if (childType != null)
{
result.Add((T)child);
}
foreach (var other in ObtenerControles(child as DependencyObject))
{
result.Add(other);
}
}
}
return result;
}