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

  • Home
  • SEARCH
  • 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 186041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:34:38+00:00 2026-05-11T15:34:38+00:00

I have a list box that contains items that are represented by a single

  • 0

I have a list box that contains items that are represented by a single textbox.

When the user clicks a button, I want to iterate thru all these text boxes and check if their binding expressions are clean of errors; Should be something like:

    Dim errCount = 0     For Each item In MyListBox.ListBoxItems 'There is no such thing ListBoxItems which is actually what I am looking for.         Dim tb As TextBox = item '.........Dig in item to extract the textbox from the visual tree.         errCount += tb.GetBindingExpression(TextBox.TextProperty).HasError     Next     If errCount Then         'Errors found!     End If 

Any discussion would be really appreciated. Thanks.

  • 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-11T15:34:39+00:00Added an answer on May 11, 2026 at 3:34 pm

    There may be an easier way to do this, but here is one option that will work:

    1) Iterate through the list of items.

    Because you are using items source, ListBox.Items will refer to the data items in the ItemsSource.

    for (int i = 0; i < ListBox.Items.Count; i++) {     // do work as follows below... } 

    2) Get the containers for these items.

    DependencyObject obj = ListBox.ItemContainerGenerator.ContainerFromIndex(i); 

    3) Use VisualTreeHelper to search for a TextBox child of the container visual.

    TextBox box = FindVisualChild<TextBox>(obj); 

    Use this function to search for a visual child of the correct type:

    public static childItem FindVisualChild<childItem>(DependencyObject obj)     where childItem : DependencyObject {     // Search immediate children     for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)     {         DependencyObject child = VisualTreeHelper.GetChild(obj, i);          if (child is childItem)             return (childItem)child;          else         {             childItem childOfChild = FindVisualChild<childItem>(child);              if (childOfChild != null)                 return childOfChild;         }     }      return null; } 

    4) Finally, examine the binding on the TextBox.

    All put together, something like this:

    private bool ValidateList(ListBox lb) {     for (int i = 0; i < lb.Items.Count; i++)     {         DependencyObject obj = lb.ItemContainerGenerator.ContainerFromIndex(i);         TextBox box = FindVisualChild<TextBox>(obj);         if (!TestBinding(box))             return false;     }      return true; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 287k
  • Answers 287k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer One way to reduce branching is to implement new features… May 13, 2026 at 5:14 pm
  • Editorial Team
    Editorial Team added an answer Not really. Normally you just set the height and width… May 13, 2026 at 5:14 pm
  • Editorial Team
    Editorial Team added an answer I'm wondering whether I should make the desktop a class… May 13, 2026 at 5:14 pm

Related Questions

I have a text box where I want to limit the number of selected
I have a problem in sql where I need to generate a packing list
I have a javascript function which would populate a list of related item in
In a pretty typical scenario, I have a 'Search' text box on my web

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.