Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It sounds like you need a <em>recursive</em> routine like GetTextBoxes below:</p> <pre><code>void Page_Loaded(object sender, RoutedEventArgs e) { // Instantiate a list of TextBoxes List&lt;TextBox&gt; textBoxList = new List&lt;TextBox&gt;(); // Call GetTextBoxes function, passing in the root element, // and the empty list of textboxes (LayoutRoot in this example) GetTextBoxes(this.LayoutRoot, textBoxList); // Now textBoxList contains a list of all the text boxes on your page. // Find all the non empty textboxes, and put them into a list. var nonEmptyTextBoxList = textBoxList.Where(txt =&gt; txt.Text != string.Empty).ToList(); // Do something with each non empty textbox. nonEmptyTextBoxList.ForEach(txt =&gt; Debug.WriteLine(txt.Text)); } private void GetTextBoxes(UIElement uiElement, List&lt;TextBox&gt; textBoxList) { TextBox textBox = uiElement as TextBox; if (textBox != null) { // If the UIElement is a Textbox, add it to the list. textBoxList.Add(textBox); } else { Panel panel = uiElement as Panel; if (panel != null) { // If the UIElement is a panel, then loop through it's children foreach (UIElement child in panel.Children) { GetTextBoxes(child, textBoxList); } } } } </code></pre> <p>Instantiate an empty list of TextBoxes. Call GetTextBoxes, passing in the root control on your page (in my case, that's this.LayoutRoot), and GetTextBoxes should recursively loop through every UI element that is a descendant of that control, testing to see if it's either a TextBox (add it to the list), or a panel, that might have descendants of it's own to recurse through.</p> <p>Hope that helps. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload