0

I have a MainWindow that has Grids, GroupBoxes and TabControls and each of them has other controls inside as a Chidren, Content or Items. I would like to know if is there a way I can get an enumerator or a collection of everyone of each control in the MainWindow.

Here is an example of the designer look like Example.jpg

I have seen some examples in other posts but all of them work only in the case that there are only childcontrols in the MainWindow.

I will appreciate so much your help.

  • 1
    Take a look at the [LogicalTreeHelper](https://msdn.microsoft.com/en-us/library/system.windows.logicaltreehelper(v=vs.110).aspx) class. – Clemens Dec 02 '16 at 11:29
  • I guess this may help http://stackoverflow.com/questions/974598/find-all-controls-in-wpf-window-by-type – Vadi Dec 02 '16 at 11:33
  • But the LogicalTreeHelper class only works for children, if I want to know the content or items it does not work. – Miqueloncio Dec 04 '16 at 18:44

1 Answers1

0

Did you try to use the VisualTreeHelper ?

With VisualTreeHelper.GetChildrenCount(...) and VisualTreeHelper.GetChild(...)

Tom
  • 38
  • 7