How to get everything in a page? RRS feed

  • Question

  • How do I get everything, like textbox, canvas, canvas inside canvas, textboxes inside canvas, grid inside stackpanel, like everything in a page or usercontrol?
    Friday, April 10, 2015 12:54 AM

All replies

  • Normally you don't: the code shouldn't care what's in the xaml. Just provide the data and let the xaml bind to it.

    If you want to enumerate the controls you can use a VisualTreeHelper.

    Friday, April 10, 2015 1:23 AM
  • Ok, I should be more clear.

    I want to add a tapped event to every textbox in my app.  This particular app is now really big, and I don't feel like going through and manually adding the tapped event to every textbox.

    So, I'm thinking I'll write a class that has a foreach that loops through everything in the pages and usercontrols and if it's a textbox then I'll add the tapped event to it.

    How would I do this?

    Friday, April 10, 2015 3:07 AM