private void GetTextBlocks(UIElement p) { if (p is TextBlock) { list.Add((TextBlock)p); }else if (p is Panel) { var pa = (Panel)p; foreach (UIElement c in ((Panel)p).Children) { GetTextBlocks(c); } }else if (p is ContentControl) { GetTextBlocks((ContentControl)p); } }