Search code examples
c#wpftabitem

loop through controls on tabitem


How can I loop through controls on a TabItem?

Somehow, I can't find the control collection of the TabItem.

What am I missing?


Solution

  • Example from MSDN:

    // Enumerate all the descendants of the visual object.
    static public void EnumVisual(Visual myVisual)
    {
        for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
        {
            // Retrieve child visual at specified index value.
            Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);
    
            // Do processing of the child visual object.
    
            // Enumerate children of the child visual object.
            EnumVisual(childVisual);
        }
    }