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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:46:56+00:00 2026-05-27T02:46:56+00:00

I have this data coming from a XML: var searched = from c in

  • 0

I have this data coming from a XML:

var searched = from c in xml.Descendants("tbody").Descendants("tr")
         let team = c.Element("td").ElementsAfterSelf("td")
         select new Time
            {
                a = c.Element("td").ElementsAfterSelf("td").First().Value,
                b = Int32.Parse(c.Descendants("td").ElementAt(3).Value),
                c = Int32.Parse(c.Descendants("td").ElementAt(4).Value),
                d = Int32.Parse(c.Descendants("td").ElementAt(5).Value),
                e = Int32.Parse(c.Descendants("td").ElementAt(6).Value),
                f = Int32.Parse(c.Descendants("td").ElementAt(7).Value),
                g = Int32.Parse(c.Descendants("td").ElementAt(8).Value),
                h = Int32.Parse(c.Descendants("td").ElementAt(9).Value),
                i = Int32.Parse(c.Descendants("td").ElementAt(10).Value),
                j = float.Parse(c.Descendants("td").ElementAt(11).Value)
            };

Done this, I’m displaying them in a ListBox:

foreach (var item in searched)
    {
         listBox1.Items.Add(item.a + "  " + item.b + "  " + item.c + "  " + 
           item.d + "  " + item.e + "  " + item.f  + "  " + item.g + "  " + 
           item.h + "  " + item.i + "  " + item.j);
         listBox1.Items.Add("  ");
    }

It prints fine, that’s how I wanted it.
Now I need to format it.
Now, it is printing like this:

a     b    c    d  e  f  g  h  j

However, the variable’s content differs in size. So the information do not get very organized.
So I wanted something like:

a|b|c|d|e|f|g|h|j

a|b|c|d|e|f|g|h|j

In which the | represents a column. I was thinking about a grid inside a list box but then I got lost on how to do it.

  • 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-27T02:46:57+00:00Added an answer on May 27, 2026 at 2:46 am

    Well, what about a ListBox with an ItemTemplate tailored to your data?

    This is the ListBox:

    <ListBox HorizontalAlignment="Left" Margin="12,6,0,0" Name="listBox1" VerticalAlignment="Top">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150" />
                        <ColumnDefinition Width="150" />
                        <ColumnDefinition Width="150" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="{Binding a}" Margin="0,0,12,0" />
                    <TextBlock Grid.Column="1" Text="{Binding b}" Margin="0,0,12,0" />
                    <TextBlock Grid.Column="2" Text="{Binding c}" Margin="0,0,12,0" />
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
    

    It uses a grid for each item, putting the values in separate columns. You can experiment with the column sizes.

    This demonstrates the binding:

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        List<MyObject> list = new List<MyObject>();
        list.Add(new MyObject() { a = 1, b = 2, c = 3 });
        list.Add(new MyObject() { a = 4, b = 57346, c = 6 });
        list.Add(new MyObject() { a = 7, b = 8, c = 9 });
    
        listBox1.ItemsSource = list;
    }
    

    I just create a list with made-up data and set it as ItemsSource of the list box. In your case the data will come from the XML.

    And I used this mock class for testing:

    public class MyObject
    {
        public int a { get; set; }
        public int b { get; set; }
        public int c { get; set; }
    }
    

    It only has 3 fields for demonstrating how it works. You can easily add the other fields as well. For each additional field add one additional ColumnDefinition and TextBlock in the XAML and set the Binding accordingly.

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

Sidebar

Related Questions

I have this ArrayCollection filled with a xml data coming from and HttpService request.
I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have to parse data from xml.this is my xml- or its url is:
I have this script that collects data from users and I want to check
I have this JavaScript code: for (var idx in data) { var row =
So I am trying to retrieve data from an XML stream coming from a
basically i have parsed some data from XML into a NSMutableArray that is shared
We have an architecture where we use SSIS to extract data from XML batch
I have a stream of xml being returned from a webservice which is coming
I have a large amount of data that I am pulling from an xml

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.