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
May be method of this kind will help you:
public static IEnumerable FindChildren(this DependencyObject source)
where T : DependencyObject
{
if (source != null)
{
var childs = GetChildObjects(source);
foreach (DependencyObject child in childs)
{
//analyze if children match the requested type
if (child != null && child is T)
{
yield return (T) child;
}
//recurse tree
foreach (T descendant in FindChildren(child))
{
yield return descendant;
}
}
}
}
See full article (Finding Elements in the WPF Tree) here.