0

I'm pretty new in develop for windows store app and I'm looking ofr a way to create a loop (foreach loop is the best for me) that will retrieve all the text boxes in the app (Which are in the xaml doc). I belive that it should look something like :

foreach(TextBox t in something)
 doAmazingThing();

My questuin is how the foreach loop should look like?

Tal
  • 337
  • 2
  • 8
  • 21
  • This could help you: http://stackoverflow.com/questions/974598/find-all-controls-in-wpf-window-by-type – Marco Jan 17 '15 at 09:23
  • @Serv thanks, but there is no more simple way to do it? – Tal Jan 17 '15 at 09:25
  • What do you mean "more simple"? Some actions require some code. Can you explain _why_ you need all textboxes? What happens in `doAmazingThing()`? – CodeCaster Jan 17 '15 at 09:31
  • @CodeCaster I just want to do a validation to a form, I have some inputs and I don't want to relate to each input seperatelly – Tal Jan 17 '15 at 09:33
  • @Tal the linked solution helps you with all elements, not just textboxes. You write it once (hopefully also understand it) and reuse it everytime you need all elements of type T. The solution is not just simple, it's also elegant and pretty darn useful – Marco Jan 17 '15 at 09:37

1 Answers1

0
foreach (Control item in this.Controls)
        {
            if (item is TextBox)
                doAmazingThing();
        }
Shamseer K
  • 4,964
  • 2
  • 25
  • 43