The VisualTreeHelper class comes handy. You can use it like this:
static public void TraverseVisualTree(Visual myMainWindow)
{
int childrenCount = VisualTreeHelper.GetChildrenCount(myMainWindow);
for (int i = 0; i < childrenCount; i++)
{
var visualChild = (Visual)VisualTreeHelper.GetChild(myMainWindow, i);
if (visualChild is TextBox)
{
TextBox tb = (TextBox)visualChild;
tb.Clear();
}
TraverseVisualTree(visualChild);
}
}