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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:21:29+00:00 2026-06-17T13:21:29+00:00

I have the following classes: public class Order { public string OrderName { get;

  • 0

I have the following classes:

public class Order
{
    public string OrderName { get; set; }
    public List<Parts> PartsList { get; set; }
}

public class Parts
{
    public string PartName { get; set; }
    public double PartQuantity { get; set; }
}

In my code I create a list of Order objects

List<Order> myOrders;

I would like to display all of this to the user somehow, like using a stack panel of elements where the first is a TextBox to display OrderName and the second is a Datagrid to display the list of Parts?

Honestly I am trying many different things (I have no requirements on what type of controls to use) but I can never get the PartsList to show correctly (either I get nothing OR I get “Collection” show to the user.

The goal would be to see something like this:

Order1    Part1    7
          Part2    12
Order2    Part1    100
          Part2    1
          Part3    58

This is the XAML I have today and I really thought it would work:

<ItemsControl x:Name="visual"
              ItemsSource="{Binding myOrders}"
              HorizontalAlignment="Stretch"
              HorizontalContentAlignment="Stretch" 
              Margin="0,397,37,31" Grid.Row="1" Height="172">
  <ItemsControl.ItemTemplate>
    <DataTemplate>
      <ItemsControl ItemsSource="{Binding }"
                    HorizontalAlignment="Stretch"
                    HorizontalContentAlignment="Stretch">
        <ItemsControl.ItemTemplate>
          <DataTemplate>
            <StackPanel>
              <TextBlock Text="{Binding OrderName}"
                         Margin="10" />
              <ItemsControl ItemsSource="{Binding PartsList}"
                            HorizontalAlignment="Stretch"
                            HorizontalContentAlignment="Stretch">
                <ItemsControl.ItemTemplate>
                  <DataTemplate>
                    <Grid HorizontalAlignment="Stretch">
                      <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                      </Grid.ColumnDefinitions>
                      <TextBlock Grid.Column="0"
                                 Text="{Binding PartName}"
                                 TextAlignment="Center" />
                      <TextBlock Grid.Column="1"
                                 Text="{Binding PartQuantity}"
                                 TextAlignment="Center" />
                    </Grid>
                  </DataTemplate>
                </ItemsControl.ItemTemplate>
              </ItemsControl>
            </StackPanel>
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>
    </DataTemplate>
  </ItemsControl.ItemTemplate>
</ItemsControl>

Does anyone see what is wrong with this code?

  • 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-06-17T13:21:30+00:00Added an answer on June 17, 2026 at 1:21 pm

    You have an extra unnecessary ItemsControl. The one with ItemsSource="{Binding}".

    So assuming that myOrders is a property which holds a collection of Orders this should work:

    <ItemsControl x:Name="visual"
                  ItemsSource="{Binding myOrders}"
                  HorizontalAlignment="Stretch"
                  HorizontalContentAlignment="Stretch" Margin="0,397,37,31" 
                  Grid.Row="1" Height="172">
      <ItemsControl.ItemTemplate>  
        <!-- This defines the DataTemplate to display one Order object-->   
        <DataTemplate>     
                <StackPanel>
                  <TextBlock Text="{Binding OrderName}"
                             Margin="10" />
                  <ItemsControl ItemsSource="{Binding PartsList}"
                                HorizontalAlignment="Stretch"
                                HorizontalContentAlignment="Stretch">
                    <ItemsControl.ItemTemplate>
                 <!-- This defines the DataTemplate to display one Parts object--> 
                      <DataTemplate>
                        <Grid HorizontalAlignment="Stretch">
                          <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                          </Grid.ColumnDefinitions>
                          <TextBlock Grid.Column="0"
                                     Text="{Binding PartName}"
                                     TextAlignment="Center" />
                          <TextBlock Grid.Column="1"
                                     Text="{Binding PartQuantity}"
                                     TextAlignment="Center" />
                        </Grid>
                      </DataTemplate>
                    </ItemsControl.ItemTemplate>
                  </ItemsControl>
                </StackPanel>        
        </DataTemplate>
      </ItemsControl.ItemTemplate>
    </ItemsControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following classes: public class Order { public string OrderName { get;
I have the following classes: public class Order { public int Oid {get; set;}
I have the following classes [XmlRoot] public class AList { public List<B> ListOfBs {get;
Given the following classes: public class Lookup { public string Code { get; set;
I have the following classes: public class Menu { public int Order { get;
I have the following two classes: public class Address { public string AddressLine1 {
I have the following classes... public class Order { private Guid id; public Guid
If i have the following classes public class Order { public virtual ISet<OrderItem> OrderItems
Suppose, I have following classes: public class DisposableObj : IDisposable { public ChildObj CreateObj();
I have the following classes: Public Class Email Private Shared ReadOnly EMAIL_REGEX = \b[a-zA-Z]+[a-zA-Z0-9._+-]+@

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.