Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 153839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:52:21+00:00 2026-05-11T09:52:21+00:00

I have several Silverlight controls on a page and want query all the controls

  • 0

I have several Silverlight controls on a page and want query all the controls that are of type TextBox and have that working.

Now the Silverlight form I’m working on could have more TextBox controls added. So when I test to see if a TextBox control has a value, I could do:

if (this.TextBox.Control.value.Text() != String.Empty) {     // do whatever } 

but I’d rather have if flexible that I can use this on ANY Silverlight form regardless of the number of TextBox controls I have.

Any ideas on how I would go about doing that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:52:21+00:00Added an answer on May 11, 2026 at 9:52 am

    It sounds like you need a recursive routine like GetTextBoxes below:

    void Page_Loaded(object sender, RoutedEventArgs e) {     // Instantiate a list of TextBoxes     List<TextBox> textBoxList = new List<TextBox>();      // 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 => txt.Text != string.Empty).ToList();      // Do something with each non empty textbox.     nonEmptyTextBoxList.ForEach(txt => Debug.WriteLine(txt.Text)); }  private void GetTextBoxes(UIElement uiElement, List<TextBox> 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);             }         }     } } 

    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.

    Hope that helps. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight controls assembly, called MySilverlightControls. Several folders down into that assembly
I have a Silverlight user control that has several canvas controls within a Stack
I have a Silverlight 4 out-of-browser application with a ScrollViewer that has several RichTextBoxes
I have several UILabels of various sizes on my Views. I want all the
I have a silverlight class library (not a top-level application) with several user controls
I'm working on a Silverlight page which has several modules for querying and plotting
I have a mvvm(model view viewmodel) silverlight application that has several views that need
In Silverlight for Windows Phone I have several view models that are disposable and
I have several pseudo-global entities in my Silverlight application that are populated with data
Okay here's the situation. Net 4 WPF NO Silverlight. I have several Views that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.