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 789835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:35:13+00:00 2026-05-14T21:35:13+00:00

i’m trying to achieve a functionality but i’m don’t know how to start it.

  • 0

i’m trying to achieve a functionality but i’m don’t know how to start it.
I’m using vs 2008 sp1 and i’m consuming a webservice which returns a collection (is contactInfo[]) that i bind to a ListBox with little datatemplate on it.

<ListBox Margin="-146,-124,-143,-118.808" Name="contactListBox" MaxHeight="240" MaxWidth="300" MinHeight="240" MinWidth="300">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock>
                              <CheckBox Name="contactsCheck" Uid="{Binding fullName}" Checked="contacts_Checked" /><Label Content="{Binding fullName}" FontSize="15" FontWeight="Bold"/> <LineBreak/>
                              <Label Content="{Binding mobile}" FontSize="10" FontStyle="Italic" Foreground="DimGray" />  <Label Content="{Binding email}" FontStyle="Italic" FontSize="10" Foreground="DimGray"/>
                            </TextBlock>

                        </DataTemplate>
                    </ListBox.ItemTemplate>
   </ListBox>  

Every works fine so far. so When a checkbox is checked i’ll like to access the information of the labels (either the) belonging to the same row or attached to it and append the information to a global variable for example (for each checkbox checked).
My problem right now is that i don’t know how to do that.
Can any one shed some light on how to do that?
if you notice Checked="contacts_Checked" that’s where i planned to perform the operations. thanks for reading and helping out

  • 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. Editorial Team
    Editorial Team
    2026-05-14T21:35:14+00:00Added an answer on May 14, 2026 at 9:35 pm

    I hear you asking to get the “information of the labels” from the row, and TimothyP has tried to explain how to do that. I could improve on his answer in several ways, but I think you are probably not asking the question you really meant to ask.

    If you want to get the data that is displayed in the labels, the easy way is to simply do that. For example, with your original template:

     private void contactscheck_Checked(object sender, EventArgs e)
     {
       var data = DataContext as MyDataObjectType;
       globalVariable += data.fullname + " " + data.mobile + "\r\n";
     }
    

    This is generally a better way to do things than to read data directly out of labels.

    If you want to get all Content from all the labels beside the checkbox in the visual tree, you can do it like this:

     private void contactscheck_Checked(object sender, EventArgs e)
     {
       var checkbox = sender as CheckBox;
       var container = (FrameworkElement)checkbox.Parent;
       var labels = container.LogicalChildren.OfType<Label>();
       var labelText = string.Join(" ",
         (from label in labels select label.Content.ToString()).ToArray());
       globalVariable += labelText + "\r\n";
     }
    

    Personally I don’t think this is as nice.

    Note that you can also change this solution to use the label name to indicate which labels you want to include:

     ...
       var labels = container.LogicalChildren.OfType<Label>()
         .Where(label => label.Name.StartsWith("abc"));
     ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.